button_to creates a discrete form. So your "button" is really a form with hidden inputs.
<form action="articles/1" method="post">
<input type="hidden" name="_method" value="DELETE">
<input type="submit">This is the button you see</button>
Also Rails is pretty damn awesome so you can simply do:
<%= button_to 'delete', article,
confirm: "Are you sure you want to delete?", method: :delete %>
And it will figure out the route by itself as long as you follow the rails conventions.
The most common reason that you get problems with link_to is that you don't have jquery and jquery_ujs included in your application.js or that you have a script error which is preventing it from doing its job. Check the browser console for errors.
Asked in February 2016Viewed 1,409 timesVoted 6Answered 2 times