Ruby on Rails
On this page:
About Ruby on Rails
Ruby on Rails, commonly known as RoR or Rails, is an open source web application framework written in Ruby. This super productive new way is used to develop real-world application with less code, compared to other application frameworks. With the introduction of Ruby on Rails, the effort of the programmer, i.e., writing millions of codes has reduced associated with an increase in productivity level of the developers.
About Ruby
Ruby is an object oriented programming language from Japan. It is an intuitive language that is pretty easy to learn. The super clean syntax of this programming language includes useful object oriented features of Ada, Perl, Python, Lisp, Dylan and CLU.
The beauty of Ruby is its simplicity and power. General features of Ruby includes:
- Major features of object oriented programming languages like global and local variables, class variables, instance and inheritance
- User-friendly expressions
- Operator overloading and exception handling
- Multi-threading and DLL or shared library support for all platforms
- Automatic garbage collection
- Portability
Ruby comes with interactive command line interpreter, which is known as 'irb'. This interpreter is used to test the codes. It is observed that the syntax of Ruby is similar to Perl and Python.
Here is an example of Ruby code:

In this example 'Person' is a class that creates object with two variables - 'name' and 'age'. Name and Age of the objects are defined inside a group. At the end of the program you can see the command:
puts group.sort.reverse
This command is written to display the output in reverse order. The system will display the objects according to their names in reverse order.
You can visit the following link to know about 'Ruby programming language':
http://en.wikipedia.org/wiki/Ruby_programming_language
About Rails
"Rails" is an open source Ruby framework, which is used for developing web application backed by huge database. Though there are several other frameworks used for developing dynamic web applications, however, Ruby on Rails has become popular across the globe because to two reasons - speed and user-friendly environment.
Today, everyone - from beginners to nonprofits to enterprise organizations - are using Rails because it is appropriate for any type of web applications. Developers are using Ruby on Rails to manage web applications efficiently. Ruby based framework is faster than any similar Java based framework. In general, all types of changes can be done in Ruby on Rails application and those changes are reflected automatically. Thus it reduces the time taking steps of web development cycles.
Following are some components of Rails:
- Active Record - Object-relational mapping layer
- Action Pack - Manager of view function and controller
- Action Mailer - Handler of Email
- Action Web Services - Handler for web services
- Prototype - Implementer of drag-drop and Ajax functionality
Here is how an ideal application directory structure of Rails looks:

It has been found that 'Rails' is more compatible web development framework that any other of its kind. With adequate support of CGI you can run Rails on most of the Web Servers. You can efficiently manage huge pool of database by using the Rail framework, which supports SQL Server, PostgreSQL, MySQL, SQLite, Oracle and DB2.
Why Ruby on Rails?
By taking help of Ruby programming language you can manage most of the complicated aspects of developing web applications. With most of the other programming languages it becomes harder for the developers to manage all issues that occur in the web environment. To overcome these problems Ruby on Rails was introduced in the market, which later gained remarkable popularity and took web development by storm. The two basic guidelines of Rails framework are - 'Limited Software' and 'Convention over Configuration'.
An application becomes competent if it is developed using less code and can be implemented easily in any environment. It has been observed that complexities in code result problems in understanding the system and maintaining it. Moreover, writing too much of code not only consumes time and effort of the developers but also complicates the debugging process of the application. Here comes the necessity of Rails, as it comes with limited software and improves the implementation process by reducing time and effort of the developers. Another approach is simplifying XML configuration. There is no need of configuring files in Rails application because it follows simple programming conventions - it can figure out everything through reflection and discovery (E.g. Rails uses intelligent reflection to automatically map database tables to Ruby objects).
Major Features
Ruby on Rails closely follows the MVC or Model View Controller architecture. In Ruby on Rails the Model consists of many classes. These classes are handled through Active Record. If this Active record base class is sub classed then the program automatically tracks which RDBMS tables to use and the columns the tables have.
Another approach is to build logic to ensure display mechanism of data from a controller class. The display logic of Ruby on Rails is known as 'View', which creates the display mechanism with limited codes. 'Controller' is another type of class, which, as a core of Ruby on Rails, manages both user interaction as well as logic of the application. End user can run 'Controller' methods through web browser and based on that request the 'Controller' class changes the data inside a 'Model' class and displays the request (data) through 'View'.
Ruby on Rails comes with wide array of useful features to simplify the effort of web development. The main objective is to make the application faster than other frameworks. This can be done through caching mechanism. In caching mechanism all types of previous functions and database calls are saved in the cache memory to save the processing time. 'Rails' offers three types of caching procedures - page caching, action caching and fragment caching.
Ensuring the validation of data is an important issue in web development and 'Rails' takes complete care of data before it goes to the database. 'Rails' provide simple processes, which validate data of any object before updating the objects and creating necessary fields in the database.
'Rails' is considered as a user-friendly application. It provides helper scripts, which is known as 'Generators' to create codes for the application. Generators are used to build new controllers and models. Even as a user you can customize the add-on generators with the help of 'Rails'.
One of the security issues in the web environment is to protect the website and the database from Cross Site Scripting. 'Rails' provides a function 'h()' and converts HTML meta characters into other HTML entities and this is implied in all the strings in the website. The 'h()' function of 'Rails' takes care of all types of HTML meta character conversion.
Transaction block is another important feature of Ruby on Rails that acts as protective block in the application where you have to run several statements together. The SQL statements of this protective block are permanent. Transaction blocks or protective blocks not only integrate the database but also guard the data from system error or misapplication of the program.
Installing Ruby on Rails
If you are working on Windows platform, you will require installing the following software to develop web application with Ruby on Rails:
- Ruby
- The Rails Framework
- Any Database like MySQL Database (and MySQL Front GUI client)
There are two major implementation of Ruby - Ruby Interpreter and Ruby implementation based on Java. Ruby is supported by most of the Windows operating systems like Windows 95/ 98/ 2000/ 2003/ NT and XP. Ruby is also compatible with other major operating systems like DOS, Unix, Mac OS X, OS/2, Syllable, Acorn RISC OS, Amiga and BeOS.
Installing Ruby 1.8.4-14 on your operating system requires selection of some basic features like - RubyGems Package Manager, FreeRIDE, Open SSL, Tcl/Tk GUI Libraries, Fox GUI Libraries and SciTE Code Editor. During installation process of ruby 182-14.exe it is recommended to follow all the instructions and defaults. Apart from these you have to install Ruby on Rail version 1.1 along with other applications like - Fast CGI 2.4.0, RubyGems 0.8.11, Readline 5.1, PCRE 6.6, FastCGI and MySQL bindings. RubyGems is a Ruby Package Manager, which is similar to other types of operating system package managers.
After installing RubyGems on the system it becomes easy to install Rails framework. You can install Rails framework and associate dependencies with the help of following command line argument:
Gem install rails - include-dependencies
After installing Ruby programming language and Rail framework you have to develop application skeleton and start that application in the web server.
Finally you have to install MySQL and MySQL -Front in the system. The process starts with downloading the current version of MySQL Windows installer followed by selecting the defaults, other configurations and security settings. The next step is to install MySQL -Front, which is a graphical interface for database. Though people do not use MySQL -Front due to cost factor but it is recommended to utilize the trial version of this application to understand its importance.