DEV Community

Sagar Kattel
Sagar Kattel

Posted on • Edited on

1

Create Hello World application in Ruby On Rails

Hello Folks,

Today we are going to learn how to create simple hello world application in ruby on rails. So hold your horses as i *embark * on you to your journey.

As you create the ruby on rails application with the command like


rails new project1
Enter fullscreen mode Exit fullscreen mode

This will create a simple ruby on rails application and now you need to enter inside it and just type

rails s 

Enter fullscreen mode Exit fullscreen mode

to start the server

Now what you need to do to display the "Hello World" application running is to go to the routes.rb file

And there specify what you want your routes folder to redirect it to:

root "controller_name#action"

root "pages#home"
Enter fullscreen mode Exit fullscreen mode

And now you need to create controller and for that you can simply write

rails generate controller pages

Enter fullscreen mode Exit fullscreen mode

This command will generate pages_controller.rb and will also generate pages folder inside views folder

And how inside the pages_controller.rb write these code

def home
end
Enter fullscreen mode Exit fullscreen mode

This command will invoke the controller to check the pages/home.html.erb file and display whatever is present there

And inside the pages folder create home.html.erb file and just type

Hello World! 

Enter fullscreen mode Exit fullscreen mode

And now you have successfully generated the Hello World Application. Sayonara <3

Neon image

Build better on Postgres with AI-Assisted Development Practices

Compare top AI coding tools like Cursor and Windsurf with Neon's database integration. Generate synthetic data and manage databases with natural language.

Read more →

Top comments (0)

AWS Industries LIVE! Stream

Watch AWS Industries LIVE!

Discover how cloud technology is solving real-world problems on Industries LIVE!

Learn More

👋 Kindness is contagious

Value this insightful article and join the thriving DEV Community. Developers of every skill level are encouraged to contribute and expand our collective knowledge.

A simple “thank you” can uplift someone’s spirits. Leave your appreciation in the comments!

On DEV, exchanging expertise lightens our path and reinforces our bonds. Enjoyed the read? A quick note of thanks to the author means a lot.

Okay