resources :photos
HTTP Verb Path Action Used for
GET /photos index-display a list of all photos
GET /photos/new new-return an HTML form for creating a new photo POST /photoscreatecreate a new photo
GET /photos/:id show-display a specific photo
GET /photos/:id/edit edit-return an HTML form for editing a photo PATCH/PUT /photos/:id update-update a specific photo
DELETE /photos/:id destroy-delete a specific photo
photos_path returns /photos
new_photo_path returns /photos/new
edit_photo_path(:id) returns /photos/:id/edit (for instance, edit_photo_path(10) returns /photos/10/edit)
photo_path(:id) returns /photos/:id (for instance, photo_path(10) returns /photos/10)
In Rails, a resourceful route provides a mapping between HTTP verbs and URLs to controller actions. By convention, each action also maps to particular CRUD operations in a database.
rake routes will output all your routes in the terminal.
You can use the match method with the :via option to match multiple verbs at once. Routing both GET and POST requests to a single action has security implications. In general, you should avoid routing all verbs to an action unless you have a good reason to.
Stay connected