I’m trying to make this be a link to a destroy action for a note :
<%= link_to "delete", @note, :method => :delete, :confirm => "Are you sure" %>
This just routes to the note and doesn’t go through to the destroy action… Whereas this:
<%= button_to "delete", @note, :method => :delete, :confirm => "Are you sure" %>
Does route properly. I’m using jQuery 1.7 and I installed the gem ‘jquery-rails’, ‘>= 1.0.12’ (which includes the jquery_ujs.js file).
What fixes are there to make link_to work properly? For some reason, I have an older app on which these link_to links work, but I can’t remember why.. Any pointers?
(I really don’t want to use button_to.. this styling is annoying, and I’m sure that there must be a way to do this..)
UPDATE: Using Rails 3.0.9
You’re not loading the
jquery_ujs.jsfile fromjquery-rails. Ensure that you’re requiring bothjqueryandjquery_ujsin your layout.These two files are typically included in the
app/assets/javascripts/application.jsfile, which contains this content:If you’re not including this in your layout with this line:
Then both the
jquery.jsandjquery_ujs.jsfiles won’t be included, and so the:method => :deleterequests will not work as intended.