0
0
Ruby on Railsframework~10 mins

Nested routes in Ruby on Rails - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a nested route for comments inside posts.

Ruby on Rails
resources :posts do
  [1] :comments
end
Drag options to blanks, or click blank then click option'
Aresources
Bresource
Cmember
Dcollection
Attempts:
3 left
💡 Hint
Common Mistakes
Using resource instead of resources for nested routes.
Using member or collection which are for different purposes.
2fill in blank
medium

Complete the code to add a nested route for reviews inside products with only the index action.

Ruby on Rails
resources :products do
  resources :reviews, only: [:[1]]
end
Drag options to blanks, or click blank then click option'
Acreate
Bshow
Cindex, :show
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Putting multiple actions as a single string instead of an array.
Using actions not allowed by the only option.
3fill in blank
hard

Fix the error in the nested route to correctly nest photos inside galleries.

Ruby on Rails
resources :galleries do
  [1] :photos
end
Drag options to blanks, or click blank then click option'
Amember
Bresources
Cresource
Dcollection
Attempts:
3 left
💡 Hint
Common Mistakes
Using resource which creates singular routes.
Using member or collection incorrectly.
4fill in blank
hard

Fill both blanks to create nested routes for chapters inside books with only show and index actions.

Ruby on Rails
resources :books do
  resources :chapters, only: [:[1], :[2]]
end
Drag options to blanks, or click blank then click option'
Ashow
Bindex
Cedit
Dnew
Attempts:
3 left
💡 Hint
Common Mistakes
Using actions like edit or new which are not requested.
Mixing up the order of actions.
5fill in blank
hard

Fill all three blanks to define nested routes for comments inside articles with only create, destroy, and update actions.

Ruby on Rails
resources :articles do
  resources :comments, only: [:[1], :[2], :[3]]
end
Drag options to blanks, or click blank then click option'
Acreate
Bdestroy
Cupdate
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Including show when it is not requested.
Missing the update action.