Delete link sends "Get" instead of "Delete" in Rails 3 view
Solution 1:
Make sure that your <head>
section in the layout includes the following:
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
In Rails 3, the delete requests are being handled with the help of JavaScript to ensure that the request is being sent correctly. If you don't have the csrf meta tags and the required JavaScript code, delete links won't work. The :defaults
JavaScript files include--among others--prototype.js, and application.js. The latter contains the stuff that makes the link work, but relies on the Prototype framework.
If you don't want to use the default Prototype JavaScript libraries, there are ports of application.js for several other frameworks. You can find the jQuery one here, for instance.
Buttons will still work regardless of JavaScript, as the HTML code generated with button_to
includes all necessary information by itself. This is why you're seeing the button work while the link doesn't.
Solution 2:
looks like
<%= javascript_include_tag :defaults %>
is no longer supported
http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/JavascriptTagHelpers/javascript_include_tag
Instead, you should use
<%= javascript_include_tag 'application' %>