0
0
Ruby on Railsframework~10 mins

Member and collection 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 member route named 'preview' inside the 'resources :articles' block.

Ruby on Rails
resources :articles do
  member do
    get '[1]'
  end
end
Drag options to blanks, or click blank then click option'
Ashow
Bindex
Cpreview
Dedit
Attempts:
3 left
💡 Hint
Common Mistakes
Using collection route names inside member block.
Using standard RESTful actions like 'index' inside member block.
2fill in blank
medium

Complete the code to define a collection route named 'search' inside the 'resources :books' block.

Ruby on Rails
resources :books do
  collection do
    get '[1]'
  end
end
Drag options to blanks, or click blank then click option'
Asearch
Bedit
Cshow
Dnew
Attempts:
3 left
💡 Hint
Common Mistakes
Using member route names inside collection block.
Using singular resource actions like 'show' inside collection block.
3fill in blank
hard

Fix the error in the code by choosing the correct keyword to define a member route named 'toggle'.

Ruby on Rails
resources :posts do
  [1] do
    post 'toggle'
  end
end
Drag options to blanks, or click blank then click option'
Acollection
Bmember
Cresource
Dresources
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'collection' instead of 'member' for single resource actions.
Using 'resource' or 'resources' keywords incorrectly inside the block.
4fill in blank
hard

Fill both blanks to define a collection route 'archive' and a member route 'publish' inside 'resources :events'.

Ruby on Rails
resources :events do
  [1] do
    get 'archive'
  end
  [2] do
    post 'publish'
  end
end
Drag options to blanks, or click blank then click option'
Acollection
Bmember
Cresource
Dresources
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping member and collection keywords.
Using 'resource' or 'resources' inside the block incorrectly.
5fill in blank
hard

Fill all three blanks to define a member route 'activate', a collection route 'stats', and a member route 'deactivate' inside 'resources :users'.

Ruby on Rails
resources :users do
  [1] do
    post 'activate'
    post 'deactivate'
  end
  [2] do
    get 'stats'
  end
  [3] do
    get 'profile'
  end
end
Drag options to blanks, or click blank then click option'
Amember
Bcollection
Dresource
Attempts:
3 left
💡 Hint
Common Mistakes
Putting member routes inside collection block.
Using 'resource' keyword incorrectly.