Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Rails lets you set up "routes" for requests, so that you can send a particular request to a controller that can handle it.
To set up a route to the index of all Page
objects, we add a line like this in config/routes.rb
:
get '/pages', to: 'pages#index'`
In plain English, you could read this as "GET requests for the '/pages' path should go to the PagesController's 'index' method".
The result is a route like this:
$ bin/rails routes
Prefix Verb URI Pattern Controller#Action
pages GET /pages(.:format) pages#index
You can read more about GET routes in the official Rails documentation.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up