Fearless Fool wrote in post #977742:
> Dai O. wrote in post #977736:
>> How do you set route to the delete action?
>
> I'm just using the premise object as the second arg to link_to:
>
> <%= link_to "delete",
>          premise,
>          :method => :delete,
>          :confirm => "Positive?",
>          :title => "Delete #{premise.address}" %>

...which can't possibly work as you'd like.  Rails is correctly 
generating the path to the show action from the object you gave it.

>
> 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.)

What you need is something like destroy_premise_path(premise) for the 
URL in link_to -- check rake routes for the exact name.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

-- 
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.

Reply via email to