0
0
Ruby on Railsframework~10 mins

Route definition in routes.rb 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 root route pointing to the home controller's index action.

Ruby on Rails
root to: '[1]'
Drag options to blanks, or click blank then click option'
A"main#index"
B"home#index"
C"home#index_action"
D"index#home"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping controller and action names.
Using incorrect action names like 'index_action'.
Using a controller name that doesn't exist.
2fill in blank
medium

Complete the code to define RESTful routes for the articles resource.

Ruby on Rails
resources :[1]
Drag options to blanks, or click blank then click option'
Aarticles
Bcomments
Cposts
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular resource names with 'resources'.
Using unrelated resource names.
3fill in blank
hard

Fix the error in the custom route definition to map GET /profile to users controller's show action.

Ruby on Rails
get '/profile', to: '[1]'
Drag options to blanks, or click blank then click option'
A"users#show"
B"profile#show"
C"users#profile"
D"show#users"
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping controller and action names.
Using a non-existent controller or action.
4fill in blank
hard

Fill both blanks to define a named route 'login' that maps GET /login to sessions controller's new action.

Ruby on Rails
get '/login', to: '[1]', as: '[2]'
Drag options to blanks, or click blank then click option'
A"sessions#new"
B"users#new"
C"login"
D"signin"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong controller or action in 'to:'.
Using incorrect or unrelated names in 'as:'.
5fill in blank
hard

Fill all three blanks to define a nested resource where comments belong to posts.

Ruby on Rails
resources :[1] do
  resources :[2], only: [:[3]]
end
Drag options to blanks, or click blank then click option'
Aposts
Bcomments
Ccreate
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of nested resources.
Using incorrect action names in 'only:'.