Hello World!
Explore how to create a custom controller and view to display a Hello World message in Ruby on Rails. Understand how to generate controllers, use Embedded Ruby in views, and configure routes to set your application's home page.
We'll cover the following...
So far, we have laid the foundation for our application, but we have yet to touch on how to customize its elements. In the tradition of programming, you will do so by making your application display some variant of the phrase “Hello World!”.
Creating a custom controller
To do this, you need a controller and a view. As you may recall, a controller’s purpose is to receive requests for the application. A router decides which controller receives which request.
To create a new controller you need to run the controller generator script in the project root directory my_project/:
rails generate controller Hello index
Running this command will create a controller called “Hello” with an
After the command has ...