This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Introduction 2:03
- Creating a Route 4:45
- Creating a Route 4 questions
- Viewing Routes 1 objective
- Adding a Route 1 objective
- Creating a Controller 2:39
- Creating a Controller 1 objective
- Creating a View 1:29
- Creating a View 1 question
- Creating a Model 3:32
- Creating a Model 1 objective
- Adding Records via Rails Console 3:17
- Populating the View 8:57
- Populating the View 2 objectives

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
Alejandro Vilches Pino
1,665 Points0 Answers
-
Teri Dent
11,515 Points1 Answer
View all discussions for this video
Related 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