Sunday, April 4, 2010

Intstall "Ruby on Rails" on Ubuntu 9.04 and Dont Repeat Yourself Anymore

My new position during initiating days of the new Iranian's year just started by a weird project that outsourced by an over seas company to an Iranian one.

I have cooperated in some software projects with different technologies such as Java, .Net and Delphi. Indeed, the latest one is a Ruby on Rails web based project that I have selected by the boss as the technology specialist and the senior developer to find out the way of using this unfamiliar technology. The project requirements and specifications ride us toward cutting edge technologies. For the first day searching and surfing through technical pages have filled my working time.

I remember some months ago, a friend of mine tried to hire some Ruby on Rails developers in Tehran. He didn't succeed. This is why I feel so lucky. Ruby on Rails is designed based on the “Convention over Configuration” idea, and the rapid development principle of “Don't Repeat Yourself(DRY)”. I have found its agile motivations so practical. I as a web developer have wast a vast of time to implement repeated and simple parts of the applications such as database connectivity and configurations. Ruby on Rails reduces this times by emphasizing CoC and DRY concepts.

Ruby on Rails is often installed using RubyGems, a package manager which is included with Ruby. Many Linux flavors also support installation of Rails and its dependencies through their native package management system.
I tried to deploy it on Ubuntu 9.04. It wasn't easy and straight forward in my case. I tried a couple of times.

I found that I have to install ruby-full and ruby-elips packages first. Next, its time to install Ruby and Rails. Leave RubyGems for the latest installation. After all you need an IDE. RadRails is an Eclipse based Ruby on Rails IDE that facilitating the developments using its nice and fast tools and services.

Here are all commands in detail:
First remove all installed Ruby, Rails, Gems and everything you will install in next steps. Any remain parts may make some troubles for this process.

Make sure your repository is updated:
sudo apt-get update

Install rails by below command:
sudo apt-get install ruby ri rdoc irb libopenssl-ruby ruby-dev

Download RubyGem.

Extract it and then install Gem by following commands:
tar xvzf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo ruby setup.rb

You don't need to the downloaded file and extracted folder any more. So remove it:
rm -r rubygems-1.3.5 rubygems-1.3.5.tgz

Now, create a set of simlinks:
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

Make sure ruby-dev installed:
sudo apt-get install ruby-dev

Next, install the Rails:
sudo gem install rails

You need Mongrel as server:
sudo gem install mongrel passenger capistrano

Setup databases (sqlite3 and MySQL):
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
sudo gem install sqlite3-ruby
sudo apt-get install mysql-client libmysqlclient15-dev
sudo gem install mysql

Test what have you done:
rails test_app

Test the application with MySQL support:
rails test-app -d mysql

Run the application:
cd test_app

No comments:

Post a Comment