Copyright ©

Ruby on Rails 2.1.x - Framework

previous next


A framework is a program, set of programs, and/or code library that writes most of your application for you. When you use a framework, your job is to write the parts of the application that make it do the specific things you want.

When you set out to write a Rails application, leaving aside configuration and other housekeeping chores you have to perform three primary tasks:

Based on the above three tasks, Ruby on Rails deals with a Model/View/Controller (MVC) framework.

Ruby on Rails MVC framework:

The Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.

Model (ActiveRecord ) :

Maintains the relationship between Object and Database and handles validation, association, transactions, and more.

This subsystem is implemented in ActiveRecord library which provides an interface and binding between the tables in a relational database and the Ruby program code that manipulates database records.

Ruby method names are automatically generated from the field names of database tables, and so on.

Active Record also provides dynamic attribute-based finders and a number of other helper methods that make database interaction easy and efficient.

View ( ActionView ):

A presentation of data in a particular format, triggered by a controller's decision to present the data. They are script based templating systems like JSP, ASP, PHP and very easy to integrate with AJAX technology.

This subsystem is implemented in ActionView library which is an Embedded Ruby (ERb) based system for defining presentation templates for data presentation. Every Web connection to a Rails application results in the displaying of a view.

Action View really helps to separate the details of presentation from the core business logic of your application.

Controller ( ActionController ):

The facility within the application that directs traffic, on the one hand querying the models for specific data, and on the other hand organizing that data (searching, sorting, massaging it) into a form that fits the needs of a given view.

This subsystem is implemented in ActionController which is a data broker sitting between ActiveRecord (the database interface) and ActionView (the presentation engine).

Representation of MVC Framework:

A Pictorial Diagram of Ruby on Rails Framework is given here:

Rails Framework

Directory Representation of MVC Framework:

Assuming a standard, default installation over Linux, you can find them like this:

tp> cd /usr/local/lib/ruby/gems/1.8/gems
tp> ls

You will see subdirectories including (but not limited to) the following:

Over a windows installation you can find them link this:

C:\>cd ruby\lib\ruby\gems\1.8\gems

You will see subdirectories including (but not limited to) the following:

ActionView and ActionController are bundled together under ActionPack.

ActiveRecord provides a range of programming techniques and shortcuts for manipulating data from an SQL database. ActionController and ActionView provide facilities for manipulating and displaying that data. Rails ties them all together.

previous next

Copyright ©