Rails.application.routes.draw do
root 'welcome#index'
endThe root 'welcome#index' line tells Rails to send requests to the root URL ('/') to the index action of the WelcomeController. This is the standard way to set the homepage of a Rails app.
Rails.application.routes.draw do root to: 'home#main' root 'home#main' end
Having two root declarations causes a routing conflict. You must have only one root route. Both root to: 'home#main' and root 'home#main' are valid, but only one should be present.
class HomeController < ApplicationController def main render plain: 'Welcome Home!' end end Rails.application.routes.draw do root 'home#main' end
The main action renders plain text 'Welcome Home!'. Since the root route points to home#main, visiting '/' shows this text in the browser.
Rails.application.routes.draw do
root 'dashboard#show'
endIf the controller or action does not exist, Rails raises an error when the route is accessed. The root route must point to a valid controller and action.
Rails.application.routes.draw do root 'pages#home' root 'dashboard#index' end
Rails requires exactly one root route. Defining multiple root routes causes a routing error on server start.