So: restful routes automatically handles seven controller actions for
you: index, new, create, edit, update, show, and destroy.
index, show, new, and edit are handled as GETs to (respectively)
recipes/
recipes/1
recipes/new
recipes/1/edit
create is handled by a POST to recipes/; update handled by a PUT to
recipes/1; destroy handled by a DELETE to recipes/1.
Whoever said "you should call it destroy"; buzzer sound for you.
#destroy is the method name we use for the end of a DELETE request.
But what if you want a page up front to handle the "are you sure you
want to destroy?" dialogue? That would be a GET to /1/delete (just
like our edit method). So, in our routes file:
map.resources :recipes, :member => {:delete => :get}
will allow you to GET recipes/1/delete with delete_recipe_path . What
this translates as is: I should be able to GET the page "delete" on
any individual recipe. If you wanted to have a new route on top of
every recipe, you could do the following:
map.resources :recipes, :collection => {:list => :get}
which allows you to GET recipes/list with list_recipes_path . This
means: I should be able to GET a list of ALL recipes.
Obviously, this should ONLY be for a page you display. If there's any
destruction in your action, you're looking for a DELETE to a recipe
path.
But the way you add extra routes on is through the :collection and
:member hashes in your routes file. Does that help?
If in doubt, type rake routes at the terminal, to see what routes your
app currently supports.