Subscriber only lesson.
Sign up to this course to view this lesson.
In this video we'll be discussing the basics of Routing in Rails.
When to use
Any time you create a web page, you need to set up a route to that web page (either automatically using the Rails Generator, or manually).
When using the Rails Generator, your route will be created automatically in the /config/routes.rb file. For our first index web page, that route will look like this:
To change the route of that page to make it our root homepage, change the above line of code to this:
That creates a "Root Route".
Remember that you can check your routes in the terminal at any time by using the "Rake Routes" command.
Hints & tips
- Every webpage needs a route
- Routes are found in the /config/routes.rb file
- A basic route looks like this: get 'home/index'
- A root route looks like this: root 'home#index'
- To view your current routes use this command in the terminal: rake routes
Lesson notes are only available for subscribers.