Sunday, March 29, 2009

Setting up a Ruby-on-Rails Development Environment

Ruby as a programming language has been around for about a decade now, but, more recently it seems to be receiving a lot of attention in the web development world. So much so, that I decided I had to take the plunge myself and find out what the buzz was all about.

After playing around with it for just a few days (couple weekends actually), I was so fascinated that I decided to write a series of blog posts about it, just in the hope that others will also be drawn to it.

So, here we go, as a "first in the series" - here's a quick draw down of how to get your system set up, so you can be on your way to creating that killer web app using RoR


One of the reasons for the massive popularity of RoR recently was the creation of the rails platform and it's power to help yo connect your front end app to a database in no time and manipulate it with ease. With that basic background, the following are the elements we will need for our little project:

1. Ruby
2. Rails Framework
3. Database System (MySQL or equivalent DB, like postgreSQL or Oracle)
4. DB FrontEnd (Like HeidiSQL or equivalent)

1. Installing Ruby

Install from the following location:

If you are a first time user, just accept the defaults.

2. Setting up the rails framework

Rails is what helps you connect your Ruby application to your database easily. Setting up the rails framework is also very easy and can be done from the
command line itself. It is kinda like installing a package in Linux.

Before we go about installing rails, we will do a quick sanity check to make sure Ruby itself was installed correctly. For this, open a command prompt and type "gem". You should see it display a help/ usage guide to the RubyGems Package manager. If you don't see this, there is a problem with the Ruby install you did in step 1, above.


RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.

gem -h/--help
gem -v/--version
gem command [arguments...] [options...]

gem install rake
gem list --local
gem build package.gemspec
gem help install

Further help:
gem help commands list all 'gem' commands
gem help examples show some examples of usage
gem help platforms show information about platforms
gem help show help on COMMAND
(e.g. 'gem help install')
Further information:

If, all is good so far, do the following to install the rails framework:

D:\Developer\Rails\cookbook>gem install rails --remote

Note: RubyGems will also install all of the other libraries that Rails depends on. For each of these dependencies, RubyGems will ask you if you want to install it. Answer "y" to each one.

That's it, you have the rails framework installed. Now, move to set up the database system

3. Setting up the DBMS (mySQL)

There are a number of free (opensource) and paid data base systems out there you can use. For my example, I am going to use mySQL.

To install mySQL, go to the following page:

The installation should be pretty straightforward -- double click the installer file to start the installer, just accept all defaults and click finish to bring up the configuration wizard. There is just one small change to be made here - when it brings up the "security panel", be sure to uncheck the "modify security settings" checkbox. The reason for doing this is because, the authentication algorithm used in mySQL may or may not be compatible with your version of rails. Unchecking it also means that you can access mySQL without a password. Other than that, accept all the default settings in the configuration wizard to complete the DB install.

4. Installing a DB FrontEnd (HeidiSQL)

The DB FrontEnd is used to access (CRUD =Create, Read, Update, Delete) a the database system, with ease. It is not absolutely essential to have this, you can access mySQL from the SQL> prompt, at the command line.But, having a nice frontend saves a lot of time and effort and makes life easy (while keeping you focused on the "bigger picture")

There are multiple free and paid applications that are frontends to SQL and Oracle database. The one I will use it called "HeidiSQL"

Install HeidiSQL from

You are now all set to develop that killer Ruby-on-Rails database driver application (I will cover the basics of doing that in the next few posts, so stay tuned!)

Oh, and do let me know (comments) if you find any errors/ issues with the above, or if you found it useful