Reputation: 23
I have tried to get this working with multiple different variations and it refuses to delete it. The box comes up asking me to confirm and when I do it takes me to the main show for that controller. I have tried link_to in multiple contexts for different controllers but none of them work. Oddly enough I had it working for a while and I'm not sure what I changed to cuase it to stop working again.
<%= link_to 'Delete Review', review, :method => "delete", :onclick => "return confirm('Are you sure you want to delete this review?')" %>
<%= link_to 'Delete Review', review, method: :delete, data: { confirm: 'Are you sure?' } %>
These are both of the ones I tried.
Upvotes: 0
Views: 63
Reputation: 25029
Check if you have included jquery_ujs
in your application.js manifest - removing Rails' JS code will stop things like delete links (and also things like forms with remote: true
) from working.
Alternatively, Javascript errors will interfere with the Rails' javascript handlers.
Upvotes: 0
Reputation: 2457
What is the context of review
?. You should pass a valid url as the second parameter.
E.g for your case you could do something like
<%= link_to "Delete Review", review_path(@review), method: :delete, data: { confirm: 'Are you sure?' } %>
Hope that helps
Upvotes: 1