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
This will create a simple ruby on rails application and now you need to enter inside it and just type
rails s
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"
And now you need to create controller and for that you can simply write
rails generate controller pages
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
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!
And now you have successfully generated the Hello World Application. Sayonara <3
Top comments (0)