Rails, Growl and Windows?
Lately I have been developing Rails apps in Windows. Don’t judge. During that time I tried multiple installation techniques from RVM in Cygwin, Ruby Installer to JRuby. The clear winner, at least for me, was JRuby. Since I like the way JRuby has been treating me, I thought I would do a high level post documenting my setup. I make the assumption that you are familiar with Ruby and Rails, and that you have enough experience to install Java and supporting applications.
As of this writing I use Windows 7 (64 bit) Professional, Java 1.7.0 (64 bit), JRuby 1.6.5, and Rails 3.1.1 but I believe these steps will be applicable for varying configurations. To get started developing in Ruby or Rails on Windows, we will need to download and install the following programs.
The “J” in “JRuby” means Java. We need to download and install the flavor of JDK (32 bit or 64 bit) that is appropriate for our system.
"JRuby is a 100% Java implementation of the Ruby programming language. It is Ruby for the JVM." That pretty much sums it up. Visit the JRuby site for the benefits of using JRuby over other implementations. My reason for using JRuby is that in my Windows experience JRuby executes faster than MRI. Installation is painless with the provided installer. Be sure to check the box to “add paths to your environment”.
Does watching the Railscasts, or Peep Code screen casts make you jealous of their Growl notifications? No more! Growl is available for windows now. When used in combination with autotest and autotest-growl it is an indispensable tool for easily tracking the status of our unit tests. Go ahead download and install Growl now.
Once we have completed installation of Java, JRuby and Growl, we can begin setting up our application.
Open up a command prompt and install the Rails gem. I already had Rails installed so do not be surprised to see
gem automatically install other dependecies. Notice that in JRuby commands are preceded with a ‘j’ so instead of
irb we will use
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\nate>jgem install rails
Successfully installed rails-3.1.1
1 gem installed
Now all we have to do is create our Rails app. Please note the
-S argument to the
jruby command. This is the recommended way to run jruby commands as documented here.
C:\Users\nate>jruby -S rails new testapp
At this point Rails will produce lines describing the creation of directories and files. Rails will also call Bundler and install those gems required by
Now we have a working Rails app. Just
cd into the directory and run it!
C:\Users\nate\testapp>jruby -S rails s
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-10 18:16:03] INFO WEBrick 1.3.1
[2011-11-10 18:16:03] INFO ruby 1.9.2 (2011-10-25) [java]
[2011-11-10 18:16:03] INFO WEBrick::HTTPServer#start: pid=5348 port=3000
Point the browser to http://0.0.0.0:3000 to view the default rails app in action. To stop the server issue
Ctrl-C twice. Proceed to setting up autotest!
Growl & Autotest
Here comes the fun part. The default install of Growl is all we need. So the only Growl configuration we have to do is to choose a notification theme, which I will leave for you. We just need to make sure Growl is running after we have installed it. Check for a claw in the system tray.
To get Growl notifications for
autotest we need to install some supporting gems. Add the following lines to the
Gemfile and run
bundle install. I use
rspec so I include
rspec-rails to the
Tell autotest that we wish to use
autotest-growl. In the
.autotest file in the root directory of our application, add the following line.
rspec using the generator.
C:\Users\nate\testapp>jruby -S rails g rspec:install
Now we will create an ‘article’ model using scaffolding.
C:\Users\nate\testapp>jruby -S rails g model article
Thats it! Run
autotest! Below is the console output with the deprecation and console color warnings removed.
C:\Users\nate\testapp>jruby -S autotest
Article add some examples to (or delete) C:/Users/nate/testapp/spec/models/article_spec.rb
# Not Yet Implemented
Finished in 14.88 seconds
1 example, 0 failures, 1 pending
If everything went well, we should see an application registration notification and a test result notification from Growl. Happy testing!