0

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 GETs. 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?

Starkers
  • 10,273
  • 21
  • 95
  • 158

2 Answers2

1

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.

Marcus Ilgner
  • 6,935
  • 2
  • 30
  • 44
0

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

Soni Kishan
  • 488
  • 2
  • 8
  • I think the OPs question is more related to the client-side which formulates the HTTP request instead of interpretation on the server. – Marcus Ilgner May 15 '13 at 13:04