I’ve just started learning Ruby on Rails and it’s a newbie question.
I did
$ rails generate scaffold Product blah blah...
and here is the snippet from the scaffold-generated view files.
<td class="list_actions">
<a href="/products/1">Show</a><br/>
<a href="/products/1/edit">Edit</a><br/>
<a href="/products/1" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a>
</td>
My question is,
Why does Ruby on Rails generate the link for “Destory” in this way? Changing method to “HTTP DELETE”…and all that.
Instead of doing it in more straight-forward way,
i.e.
<a href="/products/1/delete" data-confirm="Are you sure?">Destroy</a>
Because it’s being semantic.
Although web-browsers generally only send HTTP GET and POST requests, the semantic intention of the requests is that they map one-to-one with CRUD verbs:
… and, from a practical viewpoint, resourceful routes reflect this.