I'm using the following for a delete link:
<%= link开发者_如何学编程_to "Delete", photo_path(@photo.id), :confirm => "Are you sure?", :method=>:delete %>
Problem is, if I click CANCEL - it still deletes!!! wooops... Why is that?
First, you don't have to write photo_path(@photo.id), just pass @photo, that's enough.
<%= link_to "Delete", @photo, :confirm => "Are you sure?", :method => :delete %>
If the link doesn't work, that means that your page doesn't correctly load the JavaScript adaptator for your JavaScript framework. For example, if you use use jQuery, check this :
http://github.com/rails/jquery-ujs
精彩评论