- 720p
- 540p
- 360p
- 0.50x
- 0.75x
- 1.00x
- 1.25x
- 1.50x
- 1.75x
- 2.00x
We hope you enjoyed this lesson.
Cool lesson, huh? Share it with your friends
About this lesson
Let's build our first Rails Web Page!
Exercise files
Download this lesson’s related exercise files.
Creating Our First Web Page58.9 KB Creating Our First Web Page - Solution
248.4 KB
Quick reference
Creating Our First Web Page
In this video we'll be creating our first web page with Rails.
When to use
Rails gives you two main ways to create web pages in your app; manually or automatically using the Rails Generator.
Instructions
To create a web page with the Rails Generator, use this command in the terminal:
rails generate controller home index
Remember, all pages need a controller, an HTML file, and a route. The command above gives us a controller named home and a web page named index and creates a route for us automatically.
Hints & tips
- Rails gives us two ways to create web pages; manually or automatically using the Rails Generator
- Rails generate controller home index is the terminal command to create a web page automatically
- All web pages require a controller, an HTML file, and a route
- Routes are located in the /config/routes.rb file
- Controllers are located in the app/controllers/ directory
- Webpage HTML files are located in the app/views/home/ directory
- When using the generate command, a shortcut is to type g instead of generate
- .erb stands for embedded Ruby and allows us to use Ruby code on our web pages
Lesson notes are only available for subscribers.