开发者

Rails - Creating a Delete Link

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜