You probably already know, at least vaguely, that Rails is working on JRuby compatibility (it's most of the way there, but there are a few niggling bugs left). But did you know that Active Record also supports using a variety of databases via JDBC, which is a better fit for a JRuby-backed Rails installation than the usual sqlite or MySQL choices? As of a couple of days ago, you can easily see this in action by running the Active Record test suite. Here's how:

Grab a copy of edge Rails. You need to have a copy recent enough that it includes this commit.

You need to have JRuby installed. For the best experience with Rails, you should grab and build JRuby from its own edge. The JRubyWiki has instructions on downloading source and building yourself. Even if you don't know anything about java it's pretty simple. Here's how I did it on a Ubuntu box:

[sourcecode language='ruby']
sudo aptitude install sun-java6-jdk
mkdir jruby_trunk
svn co http://svn.codehaus.org/jruby/trunk/jruby jruby
cd jruby
svn up
ant
ant jar-complete
[/sourcecode]

I've got some aliases set up that make it easy to use JRuby as my interpreter when I want to. These go in .bash_login:

[sourcecode language='ruby']
alias jr='export PATH=/home/myuser/jruby_trunk/jruby/bin:/home/myuser/.gem/jruby/1.8/bin:$ORIGPATH'
alias mr187p72='export PATH=~/.multiruby/install/1.8.7-p72/bin:$ORIGPATH'
alias mr191rc1='export PATH=~/.multiruby/install/v1_9_1_rc1/bin:$ORIGPATH'
alias mroff='export PATH=$ORIGPATH'
[/sourcecode]

(Note that I have a couple of other Ruby versions installed on that box via multiruby as well).

You'll need to install some gems to run the Rails tests. Note the special switch to install them where JRuby will see them:

jruby -S gem install mocha mysql postgres sqlite-ruby sqlite3-ruby fcgi rack jruby-openssl

To use any of the JDBC adapters, install the glue between Active Record and JDBC:

[sourcecode language='ruby']
jruby -s gem install activerecord-jdbc-adapter
[/sourcecode]

You have your choice of lots of JDBC adapters. Let's install them all!

[sourcecode language='ruby']
jruby -s gem install activerecord-jdbc-adapter
jruby -s gem install activerecord-jdbcderby-adapter
jruby -s gem install activerecord-jdbch2-adapter
jruby -s gem install activerecord-jdbchsqldb-adapter
jruby -s gem install activerecord-jdbcmysql-adapter
jruby -s gem install activerecord-jdbcpostgresql-adapter
jruby -s gem install activerecord-jdbcsqlite3-adapter
[/sourcecode]

Time to get testing. For something easy, start with MySQL:

[sourcecode language='ruby']
cd ~/rails/activerecord
jruby -S rake test_jdbcmysql
[/sourcecode]

With edge Rails this morning, you'll get 19 test failures out of 1812 tests and 6032 assertions - not too bad. How about something more java-like, the hsqldb database engine?

[sourcecode language='ruby']
cd ~/rails/activerecord
jruby -S rake test_jdbchsqldb
[/sourcecode]

I'm getting around 600 test failures with this one at the moment.

Similar testing tasks exist for all of the other adapters I listed above. With these bits of glue coming into play, and the Rails and JRuby teams working together, we're making our way towards a point where Rails on JRuby is a robustly-supported solution.