Recall & Review
beginner
What does RESTful resource routing in Rails do?
It automatically creates standard routes for common actions like showing, creating, updating, and deleting resources, following REST principles.
Click to reveal answer
beginner
Name the 7 standard RESTful actions Rails generates for a resource.
index, show, new, create, edit, update, destroy
Click to reveal answer
beginner
What HTTP verb and path does the 'create' action use in RESTful routes?
POST request to /resources (e.g., POST /articles)
Click to reveal answer
beginner
How do you define RESTful routes for a resource named 'books' in Rails?
Use
resources :books in the config/routes.rb file.Click to reveal answer
beginner
What URL and HTTP verb does the 'edit' action use for a resource with id 5?
GET request to /resources/5/edit (e.g., GET /books/5/edit)
Click to reveal answer
Which HTTP verb is used to update a resource in RESTful routes?
✗ Incorrect
The PATCH verb is used to update an existing resource partially or fully.
What route helper does Rails generate for the 'show' action of a resource named 'posts'?
✗ Incorrect
The 'show' action uses post_path(id) to show a single post.
Which RESTful action corresponds to the URL '/articles/new'?
✗ Incorrect
The '/articles/new' URL shows the form to create a new article.
What does the 'destroy' action do in RESTful routes?
✗ Incorrect
The 'destroy' action deletes a resource from the database.
How do you limit RESTful routes to only 'index' and 'show' actions in Rails?
✗ Incorrect
Use the 'only' option to specify which actions to generate routes for.
Explain how RESTful resource routes in Rails map HTTP verbs and URLs to controller actions.
Think about how Rails uses 'resources' to create these routes automatically.
You got /3 concepts.
Describe how you would customize RESTful routes in Rails to only include certain actions.
Look at the options you can pass to 'resources' in routes.rb.
You got /3 concepts.