Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Ruby

Simple Introduction About What is Ruby on Rails

5.00/5 (1 vote)
23 Sep 2013CPOL2 min read 11.6K  
This is a simple introduction about what is Ruby on Rails.

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.

I began to learn Ruby on rails since the beginning of this August. I found out that Ruby on rails is awesome, it speeds up all my work and makes it simple to maintain. So, I wrote this article to introduce how awesome rails is.

Back to our topic, what is Ruby on rails? Web application development framework with Ruby language. For more details, you can do some searching on what is Ruby on rails, there are many sources you can find on the internet.

Installation

It is always easier to be understood by running up the things.
To install rails on your Windows or Mac PC - there is a quick way to install it by downloading rails installer and installing it.
To install rails on Linux OS such as ubuntu, debian might needs a little bit more work than Windows and Mac. There are sources on the internet, check them out.

To Begin a New Project

Before getting started with developing a new web application, you need to setup database, directory of your new project, .htaccess to control the traffic. Maybe you will spend almost half an hour to an hour to setup all those things. But …
Rails, will do it automatically for you.
By typing a few commands for it, rails will do it for you. Here are the commands:

rails new MyProject
cd MyProject
rails generate model Item name:string price:integer description:text
rails generate controller items index new create show edit update destroy
rake db:migrate
rails server

On the first command, create a new project and name it "NewProject". The second command creates a table name item and columns of name, price and description. The third command creates a directory for HTML file, Ruby file and routes. The fourth command is to startup database and the last command is to startup the server.

Everything will be setup within 1 minute. It means you can begin your programming after 1 minute. Cool, right!

Go to http://localhost:3000 and you will see the welcome message of rails.

rails2

To check with the project generated, go to http://localhost:3000/items.

The page is blank. This is because all you have generated is database, system and routes. There will be nothing to show unless HTML code is written.

Scaffold

A powerful tool that is prepared on rails called Scaffold. Scaffold will generate everything including database, simple system code, traffic, HTML layout code. It means that you can begin to code from half way instead of blank file.

How to use it? By a few simple commands.

First create a new project. In this case, named NewProject.

rails new NewProject

Then, generate scaffold with the following command and startup server.

rails generate scaffold item name:string price:integer description:text
rake db:migrate
rails server

Here’s the result generated by Scaffold. Check it out:

rails1

Instead of a blank project, Scaffold will generate a template for us to make a quick way to start.

End

It is the end of the article, do you think that ruby on rails is awesome?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)