Search⌘ K
AI Features

Hello World!

Explore how to create and customize a basic Ruby on Rails application by generating a controller, configuring views using Embedded Ruby, and setting routing to display a Hello World message on your app's home page. Understand core concepts of routing, controllers, and views to build foundational Rails skills.

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 actionActions called “index”.

After the command has ...