Many developers are confused about where to begin Ruby on Rails development. Often they are told to buy a Mac or install Linux in order to properly develop Ruby on Rails applications. However, it is quite easy to develop and deploy Ruby on Rails applications on Windows. This article will cover the basics of installing Ruby as well as the Rails framework. In addition we will cover a few editors and mention a few caveats. Finally we will talk about deploying Rails applications to a Windows Server environment.
We will cover two methods for installing Ruby on Rails. The first, Rails Installer is easy, but has a few drawbacks. The second, Ruby Installer, is a bit more involved, but presents fewer drawbacks.
Method 1: Rails Installer
Rails Installer is a great project that is designed to streamline Ruby on Rails development on Windows. It is designed to allow you to quickly get up and running with a Ruby on Rails development environment. To download it, simply grab the installer from the link above and run it. It does have a few drawbacks though. For one, the project is slow with updates, as of this writing, there still isn't any Rails 4.x support. In addition, a Ruby 2.0 package is nowhere to be found. It can also be hard to update individual packages such as Ruby or git.
Method 2: Ruby Installer
The Ruby installer method takes a bit longer to set up, but is easier to maintain and update. In addition, it gives you a better idea of what is going on under the hood. Follow the steps below to use the ruby installer method.
Grab the ruby installer from the Ruby Installer Download Page. You want the latest version of Ruby 1.9.3. Ruby 2.0.0 still has teething issues with Windows, as many gems need to be recompiled in order to work with Ruby 2.0.0. Install it to the C:\Ruby193 folder.
While you are on the Ruby Installer website, grab the devkit for Ruby 1.9.3. The devkit will be used to compile gems that don't come in binary form. You want to extract all the files to the C:\Ruby193 folder.
Grab msysgit from the msysgit download page. The latest version should be fine to use. You can install this to it's default directory or C:\git, whichever is preferable to you.
Add a path entry for git. To do this on Windows 7 you simply:
- Click the Start button
- Right Click on My Computer
- Click Properties
- Click Environment Variables...
- Look through the User Environment Variables until you find one called 'Path'
- Click the edit button.
- Append a semicolon to the end (;) and enter the path where msysgit is installed, making sure to append 'bin' to the end, for example:
C:\Program Files (x86)\Git\bin
Set up the devkit. Navigate to your Ruby folder by typing
cd C:\Ruby193and type ruby dk.rb init. Open this file in a text editor by typing
notepad C:\Ruby193\config.yml. The last 2 lines should be similar to what is listed below.
--- - C:/Ruby193
Update RubyGems. To this, simply open a command prompt and type
gem update --systemYou should see RubyGems get updated similar to the screenshot below. If you are asked to overwrite files simply type y and push enter.
Update your installed gems. Ruby Installer contains quite a few core gems that may need updated. Simply run
gem updateto update these gems. If you are asked to overwrite files simply type y and push enter.
Install Rails. To install Rails, simply type gem install rails. If you are asked to overwrite files simply type y and push enter.
The above steps will have you up and running in no time. To upgrade Ruby or the Devkit, grab the installers and follow the instructions listed above. To upgrade to a new version of rails, simply run a
gem update. This will update your gems to the latest versions.
When it comes to editors for Rails development on Windows, you have several options. Below are the three different editors, that i recommend.
Sublime Text 2 or 3
Sublime Text (Commercial, free to try, $70 to buy.) is the best Rails editor for Windows out currently. It is simple and light weight, and it's flexibility is unmatched. You can grab it at http://www.sublimetext.com.
(Free) Aptana Studio is another very good Rails Editor. Built in git integration, a terminal pane (opens a command prompt from within the editor, saves a ton of time by not having to switch between the editor and a command prompt, and much more! You can get Aptana Studio from the Aptana Website.
Below we discuss a few caveats about working with Ruby and the Rails framework on Windows. Keep in mind that this website was built in a Windows development environment, and I and many other developers find great success in developing on a Windows machine.
A Very Small Percentage of Gems aren't compatible with Windows.
Please note that despite the examples above, the majority of the gems work just fine. The only time you really get into trouble is when you use gems that provide platform specific functionality. Avoid this and you'll be fine.
Performance Can be Slightly Slower Than Linux or a Mac
Performance has gotten a lot better in the latest versions of Ruby, but Windows Ruby performance still trails behind Linux or the Macintosh Operating System.
Compiling Gems can be Difficult
One reason why i don't recommend Ruby 2.0 at this time is the lack of compiled binary gems. Things like the sqlite3 gem need to be compiled from scratch, this means you need to download the dev libraries for sqlite3 and figure out the command line options for telling the development environment where to find everything. With Ruby 1.9.3 this isn't that much of an issue because most gems have binary versions.
Despite the above mentioned issues, development on Windows is typically pretty easy. You should have very few issues overall. I develop all my Rails websites on Windows to this day.
Hosting a Rails Website on Windows
By far, the best solution I've found to hosting a Rails application on Windows is Helicon Zoo. Helicon Zoo enables Rails applications to be hosted under IIS. It is typically installed via the Web Platform Installer and installation is really easy. In the future we will try to do an in depth article on Deploying a Rails application to a Windows Server environment.
Developing Ruby applications on Windows is not only possible, but extremely easy. As long as you can avoid the caveats listed above you'll have no issues building your Rails applications. Thanks for reading!