Hello world in rails

hi..to all today we will see how to do hello world in rails

Create new application by open terminal and type the command as

$ rails new hello

$ cd hello

$ rails server

now all we need do is,change the welcome page to hello world , here are the following steps

create controller for our application using the command

$  rails generate controller home index

now go to app/views/home/index.html open with text editor and type

<h1>hello rails<h1>

save the file.

Setting the Application Home Page

Now we have to change the normal welcome board page to our hello world page

Open the config/routes.rb with text editor do the following change in root_to

  Hello::Application.routes.draw do
  # You can have the root of your site routed with “root”
  # just remember to delete public/index.html.
  root :to => ‘home#index’

finally open terminal and type the command as

$ rm public/index.html

now run the rails server page localhost:3000

Image

It shows hello rails.

Thats it.. thanks to all..

Author: Balaji

Hi..My name is Balaji and i am working as a Senior Software Developer in India. I am interested in Shell scripts, python, erlang , linux kernel .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: