I am using rails beta 3 and I have a erb page named index.html.erb for discussions controller. In that page, I have a link as following:
<%= link_to 'Delete', {:action=>'destroy', :id=>@discussion}, :confirm=>"Are you sure", :method=>'post' %>
Which is supposed to generate a link to delete a discussion, however, the generated html is
<a href="/discussions/1" data-confirm="Are you sure" data-method="post" rel="nofollow">Delete</a>
Which always routes to the show action. I think the href should be /discussions/destroy/1. But for some reason it is not.
Any ideas? Thanks in advance.
That is the correct href, but the method should be
:delete. You also need to make sure you’re properly set up with the new unobtrusive javascript way of doing things in rails 3. You might need to add thecsrf_meta_taghelper, as described in this link:http://blog.loopedstrange.com/modest-rubyist-archive/rails-3-ujs-and-csrf-meta-tags