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
"
Create a controller 👨✈️
- Go to app > controllers folder
- Create a file named
main_controller.rb
- Create a class named
MainController
and inherit fromApplicationController
- Define a method named
index
.
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
View new page 👀
- Go to http://localhost:3000
- You’ll see the new page