Marnen Laibow-Koser wrote in post #977756:
>> The generated HTML is (for example):
>>
>> <a href="/premises/2"
>> data-confirm="Positive?"
>> data-method="delete"
>> rel="nofollow"
>> title="Delete 123 Chestnut Street">delete</a>
>>
>> That looks basically right to me, so I'm still stumped.
>
> How can that look right to you? There's nothing telling Rails that you
> want DELETE or the destroy action. (The data-* attributes are
> client-side, and Rails will never see them.)
Do you mean that the :method => :delete option has no effect on the
server? The documentation suggests something different.
> What you need is something like destroy_premise_path(premise) for the
> URL in link_to -- check rake routes for the exact name.
I thought the same thing, but rake routes gives me:
premises GET /premises(.:format) {:action=>"index",
:controller=>"premises"}
POST /premises(.:format) {:action=>"create",
:controller=>"premises"}
new_premise GET /premises/new(.:format) {:action=>"new",
:controller=>"premises"}
edit_premise GET /premises/:id/edit(.:format) {:action=>"edit",
:controller=>"premises"}
premise GET /premises/:id(.:format) {:action=>"show",
:controller=>"premises"}
PUT /premises/:id(.:format) {:action=>"update",
:controller=>"premises"}
DELETE /premises/:id(.:format) {:action=>"destroy",
:controller=>"premises"}
... which, if I read this correctly, means that the delete path is still
just called "premise_path" -- the same as GET and PUT, but using a
:destroy method instead.
So it still comes back to : how do I get link_to to generate a :destroy
action? I'm sure it's and obvious and stupid error on my part. (The
perplexing things is that I've done this lots of times before...)
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.