Rails POST, PUT, GET
I believe it's specified by REST. Here's a list for ya:
GET /items #=> indexGET /items/1 #=> showGET /items/new #=> newGET /items/1/edit #=> editPUT /items/1 #=> updatePOST /items #=> createDELETE /items/1 #=> destroy
Edited to add to get all those routes, in config/routes.rb, simply add map.resources :items
Rails defines seven controller methods for RESTful resources by convention. They are:
Action HTTP Method Purpose-------------------------------------------------------------------------index GET Displays a collection of resourcesshow GET Displays a single resourcenew GET Displays a form for creating a new resourcecreate POST Creates a new resource (new submits to this)edit GET Displays a form for editing an existing resourceupdate 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.