Saturday, January 23, 2010

IronRuby 1.0 RC1 on Rails

Tonight I put 20,000 Leagues Under the Sea (1916 silent film) in the DVD player and started playing with IronRuby while the movie ran. It didn't take long for me to get engrossed in IronRuby and now I'll need to watch the movie some other time. No loss, the sound track for the movie makes good enough background music.

I decided to try the Rails tutorial on IronRuby's site. I was pleasently surprised to find instructions for ironruby_sqlserver gem which provides ActiveRecord support. The tutorial uses SQL Express, but I had no trouble using SQL 2008 Developer instead.

Everything in the tutorial worked great. After entering a few commands and creating the Post scaffold, I had a working Rails site (2.3.5) running on WEBrick with IronRuby!

The only problem I ran into was the last step of the tutorial which runs script/console. When I ran script console, as the tutorial specified (ir script\console --irb="c:\ironruby\bin\iirb.bat") I got the following error...

IronRuby.Libraries:0:in `GetExecutable': c:\ironruby\bin\iirb.bat -r irb/comple
tion -r "C:/Users/Greg/Documents/dev/ironruby/ironrubyonrails/config/environment
" -r console_app -r console_with_helpers --simple-prompt (Errno::ENOENT)
from IronRuby.Libraries:0:in `CreateProcess'
from :0:in `exec'
from C:/ironruby/lib/ironruby/gems/1.8/gems/rails-2.3.5/lib/commands/console.rb:47

To get around the error, I found I could run the commandline that line 47 was attempting run through Ruby's exec:

iirb.bat -r irb/completion -r "config/environment" -r console_app -r console_with_helpers --simple-prompt

This launched a good iirb console with access to the Rails environment!

Overall I was very pleased with IronRuby and I'll have to spend more time with it.