TAGS:

ruby  on  rails  rails  software 

First, We assume that you installed Ruby, you can know that using :

ruby -v

Then, you need to install Rails:

gem install rails

You can use –no-ri –no-rdoc , for no gems documenation

gem install rails --no-ri --no-rdoc

Also, you can know its version using :

rails -v

Now, you are ready to Rails

  • Open a terminal

  • Go to the parent folder you want to build you application there.

  • Type the following line and press Enter.

rails new autos
cd autos
  • Fire up the rails server.
rails server 
or 
rails s
  • Then,browse to localhost:3000.
  • You will see this page:

rails welcome page

Note that you can stop rails server using

ctrl + c

Also, Note that you don’t need to restart rails server every time you make changes to you application as long as you are in development environment.



Now, let’s start our autos application:

First, we will use scaffolding to create cars controller, model, views, routes, test and database migration file in one line.

rails generate scaffold car brand:string year:integer
or
rails g scaffold car brand year:integer

This single line will create:

car model

cars controller

cars views

cars routes

cars tests

cars migration file

Then we need to create cars database table using :

rake db:migrate

This line will create the cars table and its database schema in db/ folder, this table has two columns, one is brand with data type string and the other is year with data type integer.

Now, you are ready to browse you application and make CRUD operations;

CRUD means :

C for Create

R for Read

U for Update

D for Delete

Now, browse to localhost:3000, you will see the welcome page for rails application, so browse to localhost:3000/cars .

All these steps in the next tutorial video You First Rails Application