Reputation: 10551
Using Ruby and the Ruby on Rails framework, I've created three links that read from a database, edit a database entry and delete a database entry:
Show:
<a href="/inputs/2">Show</a>
Edit:
<a href="/inputs/2/edit">Edit</a>
Destroy:
<a href="/inputs/2" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a>
Edit and show are both GET
s. Delete is a DELETE
. What I want to clarify is, where are these methods defined? Is it in the link parameter data-method="delete"
? In that case, where are there no data-methods set for show and edit? Does rails just assume a link with no data-method is a GET
? And what is the significance of the rel="nofollow"
parameter?
Upvotes: 0
Views: 54
Reputation: 7231
There's a nice blog article about how data-method
attributes are converted into HTTP verbs via Javascript. In short, as you already guessed, the default is GET
for all requests issued by clicking on a link.
Upvotes: 1
Reputation: 486
The Rails router recognizes URLs and dispatches them to a controller’s action. It can also generate paths and URLs, avoiding the need to hardcode strings in your views
for more info check this
Upvotes: 0