Solution 1:

I believe it's specified by REST. Here's a list for ya:

GET    /items        #=> index
GET    /items/1      #=> show
GET    /items/new    #=> new
GET    /items/1/edit #=> edit
PUT    /items/1      #=> update
POST   /items        #=> create
DELETE /items/1      #=> destroy

Edited to add to get all those routes, in config/routes.rb, simply add map.resources :items

Solution 2:

Rails defines seven controller methods for RESTful resources by convention. They are:

Action   HTTP Method  Purpose
-------------------------------------------------------------------------
index    GET          Displays a collection of resources
show     GET          Displays a single resource
new      GET          Displays a form for creating a new resource
create   POST         Creates a new resource (new submits to this)
edit     GET          Displays a form for editing an existing resource
update   PUT          Updates an existing resource (edit submits to this)
destroy  DELETE       Destroys a single resource

Note that because web browsers generally only support GET and POST, Rails uses a hidden field to turn these into PUT and DELETE requests as appropriate.

Specifying map.resources :items in config/routes.rb gets you those seven methods "for free". You can list all the routes within your application at any time by entering rake routes in the console.

  • See Rails Routing from the Outside In for more detail.

Solution 3:

The best place to learn about this would be the Routing Guide.