Complete the code to define a nested route for comments inside posts.
resources :posts do
[1] :comments
endresource instead of resources for nested routes.member or collection which are for different purposes.Use resources to define nested routes for multiple comments under posts.
Complete the code to add a nested route for reviews inside products with only the index action.
resources :products do
resources :reviews, only: [:[1]]
endonly option.The only option expects an array of symbols. Here, [:index] limits routes to the index action only.
Fix the error in the nested route to correctly nest photos inside galleries.
resources :galleries do
[1] :photos
endresource which creates singular routes.member or collection incorrectly.Use resources to nest multiple photos inside galleries. resource is for singular resources.
Fill both blanks to create nested routes for chapters inside books with only show and index actions.
resources :books do resources :chapters, only: [:[1], :[2]] end
edit or new which are not requested.The nested chapters routes are limited to index and show actions using the only option.
Fill all three blanks to define nested routes for comments inside articles with only create, destroy, and update actions.
resources :articles do resources :comments, only: [:[1], :[2], :[3]] end
show when it is not requested.update action.The nested comments routes are limited to create, destroy, and update actions using the only option.