This tutorial will call the controller Homepage. Run the following command in your Terminal window to create a Homepage controller with an index action.
rails g controller Homepage index
Rails.application.routes.draw do root 'homepage#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end
Note: On Linux, if you run into the error FATAL: Listen error: unable to monitor directories for changes., this is due to a system limit on the number of files your machine can monitor for changes. Run the following command to fix it:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
To verify that this is working, start your application:
rails s --binding=127.0.0.1
A root route in Rails specifies what will show up when users visit the root URL of your application. In this case, you want your users to see your homepage. Open the routes file located at config/routes.rb in your favorite editor: