Installing Ruby on Rails on Mac OS X

Ruby on Rails is an open source web application framework which runs on the Ruby programming language. It is a full-stack framework: it allows creating pages and applications that gather information from the web server, talk to or query the database, and render templates out of the box. As a result, Rails features a routing system that is independent of the web server.
Ruby on Rails emphasizes the use of well-known software engineering patterns and principles, such as active record pattern,

  • convention over configuration (CoC),
  • don’t repeat yourself (DRY),
  • and model–view–controller (MVC).

 

Install Package Manager

As package manager, we choose Homebrew. (The other are Port and Flink). You can install it with

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

This will give you a terminal like the following image.

install-homebrew-terminal

 

Install Git

Git is a distributed version control and source code management (SCM) system with an emphasis on speed. Install it with the next line :

brew install git

Once Git is installed, update Homebrew with

brew update

 

Install RVM

Use RVM to pick a Ruby version for your application and guarantee that your development environment matches production. It allow you to have several version of Ruby on your mac and choose the one you want for a particular project.

!! RVM required MacPorts !! An alternative to RVM is rbenv. You can’t try :p

bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Now, make RVM available in the Shell

~/.profile
[[ -s "/Users/Nima/.rvm/scripts/rvm" ]] && source "/Users/Nima/.rvm/scripts/rvm"  # This loads RVM into a shell session.

 

Install Ruby
This simple line will install the Ruby (v1.9.3). It could take a dozen of minutes, so go drink a cappuccino 😉

rvm install 1.9.3

Now, we define this version as the default one

rvm --default 1.9.3

To specify a particular version to use, type this command line before using it

rvm use 1.9.3

 

Install bundler

Bundler manage the dependancies of Gems

gem install bundler

 

Install Ruby On Rails

Now and finally, we are gonna install Rails !

gem install rails

The last command line will install the lastest version of Rails. If you want to install a specific version, use

gem install rails -v=3.1

 

That’s all folks ! Enjoy 🙂