Installing Ruby on Rails: Windows

This tutorial will guide you through the process of getting Ruby on Rails up and running on a Windows system. Unless otherwise noted, this tutorial will apply to any version of Windows XP or Vista.

In order to begin creating web applications with Rails, you will need to install the following software:

  1. Ruby
  2. Database (typically MySQL or SQLite3)
  3. Rails

For Windows, there are basically 2 options for getting a full Rails stack up and running:

  1. Using a single all-in-one installer package
  2. Installing each component separately

Using an all-in-one installer

An all-in-one installer package includes all the software and configuration you need to begin creating Rails applications, within a single download. There are currently two popular all-in-one installer packages for Windows:

InstantRails 2.0

Bitnami RubyStack

Using an all-in-one installer versus installing components separately is a matter of personal preference. Both methods work well. For this tutorial, we are going to install each piece of software separately.

Installing software separately

1. Installing Ruby

Rails itself is written in the Ruby language, and your web application will be written in Ruby too. Ruby (sometimes referred to as the Ruby Interpreter) is an interpreted language, which means that you don't have to compile your code before running it - instead it is "interpreted" or run dynamically. So, we'll first need to install Ruby.

To install Ruby, you will need to download the Ruby one-click installer. For this tutorial, I downloaded the latest release (ruby186-27_rc2.exe).

Once you've downloaded ruby186-27_rc2.exe, double click the file and you will be presented with a standard Windows software setup wizard, which will guide you through the installation step-by-step:

Step 1: This screen tells you which version of Ruby you are installing. Click Next to continue.

Step 2: The good old License Agreement. Click I Agree to continue.

Step 3: This screen allows you to choose any additional components to install. SciTE or SCIntilla based Text Editor is a cross-platform text editor that is bundled into the Ruby one-click installer. I'd suggest leaving the defaults and Click Next to continue.

Step 4: Choose your installation location. I'd suggest leaving the default location. Click Next to continue.

Step 5: And finally, click Install to complete the installation.

You can verify your Ruby installation and version by running the following from a command prompt:
ruby -v 

2. Installing the MySQL RDBMS (Relational Database Management System)

Presumably, you'll be using Rails to create web applications that use some sort of data storage and retrieval. So, you'll need to install a database. Rails is designed to work with a wide variety of databases, but two of the most common are MySQL and SQLite3. There are many great Windows GUI tools for viewing your database tables with MySQL. So, for this tutorial, we'll install MySQL.

Download the Installer

MySQL comes in 2 Editions (MySQL Enterprise Subscription and Community Edition). For our purposes we'll use the Community Edition, which is available on the MySQL site. Here are the links to the installers:

Windows 32-bit installers

Windows 64-bit installers

Each of these options provide you with three different installer packages. For this tutorial, I'm using the Windows 32-bit Windows Essentials (x86) package. The Essentials package does not include optional components such as the embedded server and benchmark suite.

Once you've downloaded the Windows Essentials (x86) package, double click the file (for this tutorial I've downloaded: mysql-essential-5.1.34-win32.msi) and you will be presented with a standard Windows software setup wizard, which will guide you through the installation step-by-step:

Step 1: This screen tells you which version of MySQL you are installing. Click Next to continue.

Step 2: Choose your setup type. Leave the Typical option selected. Click Next to continue.

Step 3: Next, click Install to begin the installation process.

Note: During the installation process there are a couple of screens notifying you about MySQL's Enterprise edition and Monitoring Service. Just click Next on each screen.

Step 4: Once the installation completes, leave the default option of Configure the MySQL Server now checked and click Finish.

Step 5: Now we'll go through another wizard to configure our newly installed MySQL Database instance. Click Next.

Step 6: Choosing the Standard Configuration allows you to skip a few steps and is most appropriate for a single-user developer machine. So, let's choose the Standard Configuration option. Click Next.

Step 7: On the next screen set the following options:

  • Check Install as Windows Service. It's recommended so let's keep it.
  • Leave Service Name as MySQL. Unless you are already running another MySQL instance on your machine, keep this as is.
  • Check Launch the MySQL Server automatically. May as well have the Database start up automatically if you're doing regular development.
  • Check Include Bin Directory in Windows PATH. This will add the MySQL binaries to your environment variable, which may save some headaches later on.

Click Next to Continue.

Step 8: Enter a root password twice and Click Next.

Step 9: Ready to Go! Click Execute to finish the configuration wizard.

After you click Execute, if the database was configured properly you're Done! Click Finish to close the wizard.

Verify the MySQL installation

Let's confirm MySQL is up and running properly using the mysql command-line client and logging in as root. From the Start Menu choose:

All Programs --> MySQL --> MySQL Server 5.1 --> MySQL Command Line Client

A command-line window will open, where you’ll be prompted to enter the root password. Enter it, and you’ll be logged in to the command-line client!

If you see a mysql> prompt, MySQL is installed and ready to use!

3. Install Rails

To install Rails we will use the RubyGems package manager (which should be installed already as it is included with the Ruby one-click installer). Before installing Rails it's a good idea to update RubyGems to latest version. Simply enter the following at a command prompt:

gem update --system

You should see something like this:

Now we are ready to install rails. Simply enter the following at a command prompt:

gem install rails

This will take a while (several minutes or so) to complete as RubyGems needs to download and install all the rails libraries as well documentation. Once complete, you should see something like this:

To verify that rails is installed correctly and to see the current version enter the following at a command prompt:

rails -v

Congratulations! You are now ready to create Ruby on Rails web applications.

Optional Software

Console 2

Rails development usually involves several kinds of console operations, like controlling the server, interacting with the Rails console, logging in to your database or to a remote server and so on. A good way to avoid the very primitive default Windows console is to use Console 2, an open-source multi-tabbed console application that can make development on Windows easier and faster.

Running it is very simple and does not require installation; just download the zip file (not the one containing the source code), extract it in your directory of choice and run the executable.

Also available in: HTML TXT