Ruby on Rails, or just Rails is a Ruby Language, open source, web application framework.
It was extracted by David Heinemeier Hansson from his work on Basecamp project. First released as an open source project in July, 2004, share commit rights in February, 2005. In August 2006, Apple annouced that it would ship Ruby on Rails with Mac OS X v10.5 "Leopard", which was released in October 2007.
When you install Rails the specific purpose is to write Rails Web applications.
A Rails Web application is a program that takes control when someone connects to a Rails-driven Web site.
But what is a framework in the first place?
It is a set of programs and patterns that does the hard work for you. In this case, the Rails framework will turn the act of writing a web application a piece of cake
How Rails works?
Rails uses, like many other web frameworks, the Model-View-Controller (MVC) architecture pattern to organize application programming.
Rails includes a few other tools that make development tasks easier "out of the box", such as:
- Scaffolding an automatic constructor for models and views.
- WEBrick a simple ruby web server.
- Rake a batch build system.
Together with Rails these tools provide a basic development environment.
Ruby on Rails relies on a web server to run it.
Recent Rails versions uses Mongrel over WEBrick, but it can also be run by Lighttpd, Abyss, Apache (either as a module - Passenger for example - or via CGI, FastCGI or mod_ruby), and many others. From 2008 onwards, the Passenger web server replaced Mongrel as the most used web server. Recently, the Unicorn web server has become a favorite of new deployments.
Since version 2.0, Ruby on Rails by default offers both HTML and XML as output formats. The latter is the facility for RESTful web services.
Ruby on Rails relies on Ruby 1.8.6. The upcoming 3.0 version will drop support for Ruby 1.8.6 and require Ruby 1.8.7 to work.
Ruby on Rails is separated into various packages, namely ActiveRecord (an object-relational mapping system for database access), ActiveResource (provides web services), ActionPack, ActiveSupport and ActionMailer. Prior to version 2.0, Rails also included the Action Web Service package that is now replaced by Active Resource. Apart from standard packages, developers can make plugins to extend existing packages.
Ruby on Rails is intended to emphasize Convention over Configuration (CoC), and the rapid development principle of Don't Repeat Yourself (DRY).
- "Convention over Configuration" means a developer only needs to specify unconventional aspects of the application. For example, if there is a class Sale in the model, the corresponding table in the database is called sales by default. It is only if one deviates from this convention, such as calling the table "products sold", that the developer needs to write code regarding these names. Generally, this leads to less code and less repetition.
- "Don't Repeat Yourself" means that information is located in a single, unambiguous place. For example, using the ActiveRecord module of Rails, the developer does not need to specify database column names in class definitions. Instead, Ruby on Rails can retrieve this information from the database based on the class name.
Why Ruby and Rails together?
Ruby and Rails are mostly spoken of together although they both have their individual existence and can very well go without each other. The reason why they are taken together is that Ruby is the base foundation for Rails. Thus it is correct to state that they have a parent/child relationship with each other; Ruby is the parent and Rails is the child.
We can work very easily on Rails if we have knowledge of Ruby since the basic conventions of Rails are similar to conventions of Ruby. But that doesn't mean that we can't work on Rails if we haven't worked on Ruby. The efforts in programming will definitely increase and also the time taken to develop your application and go live will increase if you are not already familiar with Ruby. It helps a lot to understand the code of Rails and it's functionality if we have knowledge of Ruby while working on Rails and so they both go side by side.
Ruby helps a programmer to be a better developer by giving him a better understanding of the code he is working with. It makes programming easier as the developer is familiar with the readily available idioms and conventions of Ruby.
Knowledge of Ruby also makes debugging quite an easy task for the programmer when he is working with Rails.
Compared to the other programming languages and development environments, Ruby on Rails is a very efficient way of developing successful web applications in a shorter time.