views:

302

answers:

1

When I do a rake routes, I see that helper methods are available for certain REST actions for my user model such as new_user, edit_user so I can use methods like new_user_path, edit_user_path etc but they are not available for update or destroy action. To invoke the destroy action, I have to do something like this

link_to ‘Destroy’, user_path, :method => :delete

Anyone know why this is the case?

+1  A: 

Simply because there is no need. A combination of http verb and URI should be sufficient to determine whether it is an update or destroy action. here is a list of http verb and URI combination from rails guide, from which you can see 'update' and 'destroy' share the same URI as 'show', the only difference is http verb.

GET /photos Photos index display a list of all photos

GET /photos/new Photos new return an HTML form for creating a new photo

POST /photos Photos create create a new photo

GET /photos/1 Photos show display a specific photo

GET /photos/1/edit Photos edit return an HTML form for editing a photo

PUT /photos/1 Photos update update a specific photo

DELETE /photos/1 Photos destroy delete a specific photo

ez
While 'update' and 'destroy' share the same URI as 'show', for consistency sake, I would argue that it is better to having matching update and destroy helper methods, it's what I was looking for initially and couldn't get working until I saw a post on the different style of method call for 'update' and 'destroy'.
Bob