Something I’ve been working on mastering is the routes.rb
file.
Below is a sample question I worked on with my answers:
What urls does this code in your routes.rb file generate:
Write out each url, its http verb, and the controller method that it will map back to.
HTTP Verb | Path | Controller#Action | Used for |
---|---|---|---|
GET | /posts/:post_id/comments | comments#index | display a list of all comments for a specific post |
GET | /posts/:post_id/comments/new | comments#new | return an HTML form for creating a new comment belonging to a specific post |
POST | /posts/:post_id/comments | comments#create | create a new comment belonging to a specific post |
GET | /posts/:post_id/comments/:id | comments#show | display a specific comment belonging to a specific post |
GET | /posts/:post_id/comments/:id/edit | comments#edit | return an HTML form for editing a comment belonging to a specific post |
PATCH/PUT | /posts/:post_id/comments/:id | comments#update | update a specific comment belonging to a specific post |
DELETE | /posts/:post_id/comments/:id | comments#destroy | delete a specific comment belonging to a specific post |