Root route

suggest change

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"  
end

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

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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents