Loading...
📕
6 How to add a root route
⬅️
index
You need to replace the default,
“Yay!
You’re on Rails” landing page with a real index page for your app.
Create a route
🛤️
Go to
config > routes.rb
file
In the
Rails.application.routes.draw
method, enter the route:
get root, to:
"
main#index
"
routes.rb
Create a controller
👨✈️
Go to
app > controllers
folder
Create a file named
main_controller.rb
Create a class named
MainController
and inherit from
ApplicationController
Define a method named
index
.
main_controller.rb
Create a view
🏞️
Go to
app > views
folder
Create a folder named
main
In that folder create a file named
index.html.erb
Add HTML
app > views > main > index.html.erb
View new page
👀
Go to
http://localhost:3000
You’ll see the new page
localhost:3000/
⬅️
index
Please turn on JavaScript to use Paper in all of its awesomeness. ^_^
Create a route 🛤️
Create a controller 👨✈️
Create a view 🏞️
View new page 👀