Home » Web

Ruby on Rails Tutorial

18 February 2011 No Comment

Ruby on Rails TutorialWhat is Ruby on Rails? Ruby on Rails, often shortened to Rails or RoR, is an open source database-backed web application for the Ruby programming language. It is intended to be used with an Agile development methodology which is used by web developers for rapid development.

It is a web application framework similar to Django, if you know Python. Using a web application framework will make your web development so much faster and easier.

Rather than focusing your time on setting up your web application, you can instead, focus on building your content. It focuses Rail’s guiding principle: less software and convention over configuration.

What does that mean? Less software means that you need to write less code to implement your application. Writing less code means less bugs, faster development, and makes it easier to maintain and understand. Convention over configuration means that it uses simple programming conventions to figure things out. For example, your application and your database already contain the default settings needed for Rails to run out of the box. You will understand what I mean as we get into more details below.

To get started, please visit the official Ruby on Rails site.


Ruby on Rails uses Model-View-Controller (MVC) architecture. This architectural pattern isolates application logic from the user interface. The isolation allows for independent development and testing. You also get the benefit of rapid development principle of Don’t Repeat Yourself (DRY). DRY means that information is stored in a single, unambiguous place. For example, when you use the ActiveRecord module with Rails, you do not need to specify the database columns in class definitions. This information is retrieved from the database itself based on the class name.


The model part of Rails is where manipulation of data is being performed. Essentially, it is the location for managing the rules for the interaction with the database tables. The bulk of your business logic will be in the model. For example, one table in your database will correspond to one model in your application.


The view part of Rails presents the user interface of your application. In Rails, views are like HTML files that have embedded Ruby code. Its main purpose is to provide data to your web browser. Requests from your application are generated and presented to the user by the code within the views.


The controller part of Rails is the “glue” between the model and the view layer. It is responsible for processing the incoming requests from the web server, verifying the data from the model layer, and passing the data to the view layer for the presentation.

The controllers are not concerned with how the data is presented. That is the job of the view layer. It is more concerned about the application logic and making sure everything falls in place.

Generating Code

When you write code, it would be nice if there are certain things that can be created automatically for you. In Rails, this concept is called scaffolding. It is a set of code generators that saves you time during your initial development. Just like building a house, there are temporary structures such as tubes, couplers and boards.

In Rails, the scaffolding concept extends to the automatic generation of HTML pages and directory names and files. These files and conventions can definitely be changed but they provide the framework for consistency and convention over configuration.

Ruby on Rails Tutorial

Free Ruby and Rails Screencasts

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.