bishopeous

bishopeous header image 2

Setting up a rails dev environment - Part 1: Ruby, Rails and RadRails

February 27th, 2007 · No Comments

One of the projects I am working on is a Standards Information Base (SIB) to support our enterprise architecture work. As this is a relatively small implementation project we’ve taken the opportunity to introduce Ruby on Rails. The following recipe documents how we have set up our development environment for rails on Windows XP Professional with Service Pack 2. It may not be the most elegant solution but it fits nicely with the range of other dev tools we have installed. This is part one of a four part series. Follow all four parts and you will have everything you need to develop and deploy a rails application.

The first part in this recipe is about getting the basics in place: ruby, rails, a web server, a database and a development tool.

Install InstantRails

The first thing to do is to download the latest version of InstantRails (currently version 1.5). This gives you ruby, rails, apache and mysql packaged up and ready to run. All you need to do is unzip the contents to a local drive. This folder will hold all the Ruby on Rails related applications. It is a good idea to make sure that you use a location that has no spaces in the path as this will, at some point, break something. For this recipe we’re placing the folder in the root of the C drive:

C:\\InstantRails

Later in the recipe we install RadRails. To help in running it from InstantRails’ ruby console you need to change the following line in InstantRails\conf_files\use_ruby.cmd

PATH ${path}\\ruby\\bin;${path}\\mysql\\bin;%PATH%

to

PATH ${path}\\ruby\\bin;${path}\\mysql\\bin;${path}\\radrails;%PATH%

At this point you need to rename the InstantRails directory. This will force InstantRails to apply the change in the path to the relevant files. Rename the InstantRails directory to RubyOnRails

C:\\RubyOnRails

This is now the root directory for your rails dev environment. For the rest of the recipe this directory is referred to as RubyOnRails.

InstantRails is now ready to run. Run InstantRails.exe and you should see something like this:

It is a good idea to check that RubyOnRails\use_ruby.cmd is correct. You should have something that looks like this:


:------------------------- WARNING ! ----------------------
:         This file is GENERATED by Instant Rails.
:
: If you need to make changes to this file, you should edit
: the source template file instead. The source template is
: C:\\RubyonRails\\conf_files\\use_ruby.cmd
:-----------------------------------------------------------
CD C:\\RubyonRails
PATH C:\\RubyonRails\\ruby\\bin;C:\\RubyonRails\\mysql\\bin;C:\\RubyonRails\\radrails;%PATH%
cd rails_apps
dir

I have found that sometimes the ${path} in RubyOnRails\conf_files\use_ruby.cmd is not expanded out properly when it is copied to RubyOnRails\use_ruby.cmd by InstantRails. You may need to manually edit it just to make sure that the paths are correct. If you make any changes, restart InstantRails. Once running, hit F2 to start the apache and mysql servers.

Install RadRails

RadRails is an eclipse-based IDE for Ruby on Rails. To run it you need to have version 1.4.2 or later of the Java runtime installed:

C:\\RubyOnRails> java -version

RadRails comes in two flavours: as a standalone version with eclipse included, and as a set of updates for an existing eclipse installation. For this recipe, we’ll use the standalone version so we don’t introduce problems with other tools that use eclipse. Download the latest version (currently version 0.7.2) and unzip it into your RubyOnRails directory. The directory should now look something like this:

Run RadRails:

c:\\RubyOnRails> radrails

You shouldn’t need to change any of the ruby settings in RadRails unless you installed ruby separately. Details of what you need to do can be found here: http://www.radrails.org/blog/2006/9/16/radrails-0-7-1-and-windows-xp-how-to-configure

Install HeidiSQL

InstantRails does not include a graphical management tool for the MySQL database. This is easily fixed by downloading and installing the latest version of HeidiSQL (currently Version 3 RC4), an open source interface for MySQL. This will install in the Windows default location (probably C:\Program Files). Once installed you can try and connect:

The MySQL server running in InstantRails is configured with the username root. The password is blank.

A note about changing the username/password for MySQL in InstantRails

In short, don’t. Everything seems to break if you do. The only thing you must remember to do is to set a proper username/password for your production server.

Get the documentation together

If you don’t have a PDF reader installed you will need to do that before going any further. You can find the Adobe reader here, but there are others available.
Create a directory for the documentation in the RubyOnRails directory, something like RubyOnRails/docs will do nicely. Download the following and put it in your docs directory:

  1. Ruby documentation bundle
  2. Ruby programming course 
  3. Humble little ruby book
  4. Why’s poignant guide to ruby
  5. Rails api. Download the latest zip file and then copy the doc/api directory into your doc directory.
  6. Rails cheatsheet
  7. 4 Days on Rails tutorial
  8. Version control with Subversion
  9. MySQL Manual
Agile Web Development with Rails - Second Edition

Unlike the documentation above, this book costs money. It is worth the investment as it will take you through all the steps of putting together a rails app, something that this recipe doesn’t do. You can purchase the PDF version here: http://www.pragmaticprogrammer.com/titles/rails/index.html

In the next part, we will look at installing some ruby gems.

Tags: development · rubyonrails

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment