Installing Ruby on Rails on Windows
April 5, 2014 Leave a comment
Following is a record of the steps that I followed to install Ruby on Rails, as well as a few Ruby add-on packages, on Windows 7. While this is somewhat of a rough draft (and therefore may not be entirely repeatable), it should at least provide some guidance.
http://rubyonrails.org/ – The official Ruby On Rails web site
http://rubyinstaller.org/ – “The easy way to install Ruby on Windows”
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit – How to install the Ruby Development Kit
Installation of Ruby on Rails
Step 1) Go to http://rubyinstaller.org/, which bills itself as "The easy way to install Ruby on Windows". The RubyInstaller project provides a Windows installer that includes Ruby, a baseline set of RubyGems, and the full text of "The Book of Ruby".
Step 2) Navigate to the downloads page ( http://rubyinstaller.org/downloads/ ), and review the information found there.
Step 3) Determine the appropriate version of Ruby to install. In my case, I needed to install Ruby in order to evaluate a Ruby on Rails application. That application used an older version of Rails, so the best version of Ruby was the 1.8.7 release. The download page at RubyInstaller.com can help you determine what version to use. Otherwise, use your favorite search engine to do the research needed to identify the best version for you.
Step 4) Download and run the RubyInstaller package. You can choose the folder in which Ruby gets installed. (For the rest of this tutorial, assume that Ruby is installed in C:\Ruby.)
Step 5) Optional, but recommended. From http://rubyinstaller.org/downloads/, download the appropriate Development Kit for the version of Ruby that you selected. Follow the instructions at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit to install it. You may not need this, but it seems likely that you will. I tried adding some gems required by the application I was evaluating, and the first thing that happened was an error because "installed build tools" were required… and one way to take care of that error is to install the Development Kit.
Here are the detailed steps for installing the Development Kit.
a) Download the Development Kit
b) Extract it to a permanent location (say C:\RubyDK)
c) In a command prompt, navigate to the root folder for the Development Kit (for example, C:\RubyDK)
d) Execute "C:\Ruby\bin\ruby dk.rb init"
e) Execute "C:\Ruby\bin\ruby dk.rb install"
Step 5) Navigate to C:\Ruby\bin, and install Rails by typing "gem install rails". To install a particular version of Rails, include the version number with the -v option. For example, "gem install rails -v 2.3.5".
At this point, you should have everything you need to get started. To actually do something with Ruby on Rails, continue with the next steps.
Step 6) Create a new Rails application by typing "rails new <application path>"
Step 7) Start the new application by navigating to the application root and typing "rails server"
Step 8) Confirm that the application is running by using a browser to navigate to http://localhost:3000
ImageMagick is a popular open-source tool for performing operations with image files. I found it to be a challenge to get it configured to work with Ruby on Windows.
To install/configure ImageMagick with Ruby, the gem (Ruby add-on) that needs to be installed is RMagick. The process that I followed to install RMagick is detailed at https://github.com/rmagick/rmagick/issues/27#issuecomment-4634069.
In brief, the steps are:
1) Install Ghostscript
2) Install ImageMagick
3) Open a new command window and install the RMagick gem. Use a command something like:
gem install rmagick –platform=ruby — –with-opt-lib=C:/ImageMagick-6.7.6-Q16/lib –with-opt-include=c:/ImageMagick-6.7.6-Q16/include
While this worked, it required an older version of ImageMagick. I used ImageMagick 6.5.6 (found in the rmagick-win32 gem package that can be downloaded from http://rubyforge.org/projects/rmagick/). Alternately, I’ve saved a copy at this location.
I was working with with Ruby 1.8.7 and RMagick 1.8.24. If you are using a newer version of Ruby and/or the RMagick gem, it may be possible to also use a newer version of ImageMagick.
A Note About Deployment
I found a lot of information on the web that suggests that deploying Ruby on Rails under Windows is painful, at best. This article ( http://editrocket.com/articles/ruby_apache_windows.html ) suggests an easy way to configure Apache for Ruby… I did not try this method, so I cannot confirm its contents.