Ruby on Rails Routing Root route


You can add a home page route to your app with the root method.

# config/routes.rb
Rails.application.routes.draw do
  root "application#index"
  # equivalent to:
  # get "/", "application#index"  

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  def index
    render "homepage"

And in terminal, rake routes (rails routes in Rails 5) will produce:

root     GET    /         application#index

Because the homepage is usually the most important route, and routes are prioritized in the order they appear, the root route should usually be the first in your routes file.