Complete the code to define a member route named 'preview' inside the 'resources :articles' block.
resources :articles do
member do
get '[1]'
end
endThe member block defines routes that act on a single resource. Here, 'preview' is a member route for an article.
Complete the code to define a collection route named 'search' inside the 'resources :books' block.
resources :books do
collection do
get '[1]'
end
endThe collection block defines routes that act on the collection of resources. 'search' is a typical collection route.
Fix the error in the code by choosing the correct keyword to define a member route named 'toggle'.
resources :posts do [1] do post 'toggle' end end
The 'toggle' action acts on a single post, so it must be inside a member block.
Fill both blanks to define a collection route 'archive' and a member route 'publish' inside 'resources :events'.
resources :events do [1] do get 'archive' end [2] do post 'publish' end end
'archive' applies to the whole collection, so it goes in collection. 'publish' acts on one event, so it goes in member.
Fill all three blanks to define a member route 'activate', a collection route 'stats', and a member route 'deactivate' inside 'resources :users'.
resources :users do [1] do post 'activate' post 'deactivate' end [2] do get 'stats' end [3] do get 'profile' end end
'activate' and 'deactivate' are actions on individual users, so they go in member. 'stats' is for the whole collection, so it goes in collection. 'profile' is also a member route.