📕 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 🛤️ 

  1. Go to config > routes.rb file
  1. In the Rails.application.routes.draw method, enter the route:
  • get root, to: "main#index"

Create a controller 👨‍✈️ 

  1. Go to app > controllers folder
  1. Create a file named main_controller.rb
  1. Create a class named MainController and inherit from ApplicationController
  1. Define a method named index.

Create a view 🏞️ 

  1. Go to app > views folder
  1. Create a folder named main
  1. In that folder create a file named index.html.erb
  1. Add HTML

View new page 👀 

  1. You’ll see the new page


⬅️ index