It looks like the issue with your link_to “delete” not triggering the delete action is related to the jquery_ujs JavaScript file not being included or loaded properly.


Ensure jquery_ujs is Included:

Add this line to your app/views/layouts/application.html.erb within the tag to explicitly include jquery_ujs:

<%= javascript_include_tag 'jquery_ujs' %>

Verify jQuery is Included:
Since jquery_ujs depends on jQuery, make sure jQuery is included before jquery_ujs. This can usually be handled by the asset pipeline in Rails 3.2, but it’s good to verify:

<%= javascript_include_tag 'jquery' %>

Your app/assets/javascripts/application.js should look something like this:
//= require jquery
//= require jquery_ujs
//= require_tree

How jquery_ujs Works:

jquery_ujs is an JavaScript driver that reads the data-method attribute and converts the link’s action to a form submission with the specified HTTP method (in your case, DELETE). Without it, your link_to “delete” just follows the standard hyperlink behavior, usually triggering the show action instead of delete.

Following these steps should resolve the issue and enable the delete action to work as expected. If the problem persists, check your browser’s console for any JavaScript errors.

Support On Demand!

Ruby on Rails