My Ruby on Rails on Windows setup

I am not a Windows fanboy but sometime I have to use it. Here is my current Ruby on Rails environment setup on Windows 7.

Since I dealing with console (Command Prompt) a lot, so before I setup Ruby and Rails, I install these 2 nifty tools first.

Console

Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles.

Get it here.

ANSICON

I like colored console output mainly because I often dealing with log files. ANSICON is a tool that provide those colors.

Here is how I install it

  • Extract ansi140.zip to C:\bin so you have C:\bin\ansi140
  • Add C:\bin\ansi140\x86 to Path
  • Fire the Command Prompt, type and enter: ansicon -i

The last command you run will install ansicon permanently. To uninstall ansicon, simply close any programs that currently using it and run ansicon -u from the Command Prompt.

Now the Ruby part. In summary, I install the 1.8.7 version first, then pik the Ruby version manager and then the Ruby Development Kit.

Ruby 1.8.7

Download and run rubyinstaller-1.8.7-p334.exe, install Ruby in their default folder C:\Ruby187 and don’t forget to check ‘Add Ruby executables to your PATH’.

Open up a Console and execute

ruby -v 

and you should get

ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]

pik

First, you want to update your gem

gem update --system

I usually don’t need ri and rdoc from the installed gems so I disabled it by default. Create a file named .gemrc in your home directory

C:\Users\YourUserName

with the following content

gem: --no-ri --no-rdoc

Now install pik

gem install pik

Read the rest of the installation manual here

Development Kit

Installing native gem has never been easy for Windows people, until DevKit came in into the scene. Follow the detailed instruction here.

Download DevKit and extract to C:\DevKit then from a Console

cd C:\DevKit
ruby dk.rb init

Test your installation by installing rdiscount gem

gem install rdiscount --platform=ruby

rdiscount should installed correctly

ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html

you should see

<p><strong>Hello RubyInstaller</strong></p>    

XAMPP (for the MySQL)

No suprise that you will also need MySQL on your Windows setup. I use XAMPP. To connect your Rails app to MySQL you will need mysql2 gem. This is how to install mysql2 on Windows 7 using XAMPP

gem install mysql2 -- --with-mysql-include=C:\xampp\mysql\include --with-mysql-lib=C:\xampp\mysql\lib\opt

Done!

Now you are ready to build the next big thing in web application industry using Rails right from your Windows box.