Ruby and Rails….The Developers Choice….

January 31, 2010

The Rails framework is built using the Ruby programming language, and a better understanding of Ruby is essential to mastering Rails.The Rails framework is composed of several different Ruby libraries. Rails is a full stack framework , which means it contains all the tools needed to get a basic application up and running. The Rails stack is split into various components that we’ll often refer to by name.

Installation is different on various platforms , and there are some great packages that simplify the Rails install process. You can find the most up to date install process on the Rails download page. Although often thought of as a single unit , Ruby and Rails are two separate packages. Rails is a framework written in the Ruby language, not unlike frameworks such as Cake and the Zend framework in PHP. To get Rails working , your first step will be to get Ruby installed on your machine. I recommend installing Ruby version 1.8.6 or newer. Once you have Ruby installed , we have to take a quick look at package management in Ruby. The most common method of distribution for Ruby packages and libraries is through RubyGems. RubyGems is a package manager similar to PEAR for PHP , and Rails is most easily installed on your computer through gem. I recommend installing RubyGems 1.0.1 or newer , which you can download from the Ruby Forge website.

Rails is an opiniated web framework , and one of the opinions is that you will use Subversion. Doing so will reward you with nice features of Rails that integrate well with Subversion.Knowledge of Subversion will come in handy while deploying your application , installing third party plug ins ,and submitting patches to Rails itself if you decide to contribute to Rails.

David Heinemeier Hansson extracted Rails from an application he wrote for his company , 37signals. He released it as open source in 2004 , and there is now a group of developers on the core team actively applying features and patches to Rails. David’s original framework actually began in PHP , but he later found Ruby to be a much better fit for what he needed to do.

Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Control pattern.

This pattern splits the view (also called the presentation) into “dumb” templates that are primarily responsible for inserting pre-built data in between HTML tags. The model contains the “smart” domain objects (such as Account, Product, Person, Post) that holds all the business logic and knows how to persist themselves to a database. The controller handles the incoming requests (such as Save New Account, Update Product, Show Post) by manipulating the model and directing data to the view.

In Rails, the model is handled by what‘s called an object-relational mapping layer entitled Active Record. This layer allows you to present the data from database rows as objects and embellish these data objects with business logic methods. You can read more about Active Record in  files/vendor/rails/activerecord/README.html.

The controller and view are handled by the Action Pack, which handles both layers by its two parts: Action View and Action Controller. These two layers are bundled in a single package due to their heavy interdependence. This is unlike the relationship between the Active Record and Action Pack that is much more separate. Each of these packages can be used independently outside of Rails. You can read more about Action Pack in files/vendor/rails/activerecord/README.html.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: