Rails simulates a DELETE on a resource by using POST and a hidden field in the Form. But that makes it a must to use a form to delete a record.
However if I wanted to delete a row via a Anchor tag ‘Delete’ displayed at the end of the row how would I achieve the same? So say I am displaying people records and my rows looks like:
||First Name|| Last Name||
||Foo || Bar || Delete
||Baz || Foo || Delete
…
And on the delete click I want to route to /people/:id/destroy without using a Form and Hidden field?
Rails’ link_to method supports the
GET,POST,PUT, andDELETEHTTP verbs. For example, you could do something like:http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to