4.3 Setting the Application Home Page

Now that we have made the controller and view, we need to tell Rails
when we want Hello Rails! to show up. In our case, we want it to show up
when we navigate to the root URL of our site, http://localhost:3000. At
the moment, "Welcome Aboard" is occupying that spot.

Next, you have to tell Rails where your actual home page is located.

Open the file config/routes.rb in your editor.
Blog::Application.routes.draw do
  get "welcome/index"

  # The priority is based upon order of creation:
  # first created -> highest priority.
  # ...
  # You can have the root of your site routed with "root"
  # root to: "welcome#index"

This is your application's routing file which holds entries in a special
DSL (domain-specific language) that tells Rails how to connect incoming
requests to controllers and actions. This file contains many sample
routes on commented lines, and one of them actually shows you how to
connect the root of your site to a specific controller and action. Find
the line beginning with root and uncomment it. It should look something
like the following:
root "welcome#index"

The root "welcome#index" tells Rails to map requests to the root of the
application to the welcome controller's index action and get
"welcome/index" tells Rails to map requests to
http://localhost:3000/welcome/index to the welcome controller's index
action. This was created earlier when you ran the controller generator
(rails generate controller welcome index).

If you navigate to http://localhost:3000 in your browser, you'll see the
Hello, Rails! message you put into app/views/welcome/index.html.erb,
indicating that this new route is indeed going to WelcomeController's
index action and is rendering the view correctly.