Routes Flashcards
1
Q
Say you have an article model, how can add routes for all the CRUD actions for your article model and how would you exclude/include specific routes by their action?
A
resources :articles
resources :articles, only: [:index]
resources :articles, except: [:index]
2
Q
How do you set the root path for your app?
A
root controller: :landing, action: :index
3
Q
How can you automatically redirect visitors to the landing page when there is an routing error? So if a user wants to visit the poop page, what can you add to your routes.rb to redirect them to your landing page?
A
get ‘*path’ => redirect(‘/’)