I'm trying to setup a link that deletes a database entry, and everything works as intended, it just doesn't ask for confirmation first. I think I've done everything right, I'm testing this in firefox on ubuntu.
<%= link_to "Delete", @post, :confirm => "Are you sure you want to delete?", :method => :delete %>
any help is appreciated.
Read the documentation carefully
:
:data
- This option can be used to add custom data attributes.
Data attributes
confirm: 'question?'
- This will allow the unobtrusive JavaScript driver to prompt with the question specified (in this case, the resulting text would be question?. If the user accepts, the link is processed normally, otherwise no action is taken.
Your link_to
should be like this:
<%= link_to "Delete", @post, data: { :confirm => "Question?", :method => :delete } %>