Sunday, February 10, 2008

JRuby on Rails - First project

I have been wanting to explore jruby on rails for sometime, I finally managed to scramble together a small working project and like what I am seeing.

So this is what I did on my Windows box:

1. Install JRuby. I have installed the latest RC available at this time - 1.1RC1

2. Set the Environment variables -
JRUBY_HOME
PATH - to the bin directory of JRUBY_HOME

3. Install Rails:
jruby -S gem install rails --include-dependencies --no-ri --no-rdoc

4. Install jdbc adapter:
jruby -S gem install activerecord-jdbc-adapter

5. Install Derby adapters:
jruby -S gem install activerecord-jdbcderby-adapter

6. Install Mongrel - To use Mongrel as the webserver instead of the default, download http://rubyforge.org/frs/download.php/20097/mongrel-1.0.1-jruby.gem and,
jruby -S gem install gem_plugin --no-ri --no-rdoc
jruby -S gem install cgi_multipart_eof_fix --no-ri --no-rdoc
jruby -S gem install mongrel-1.0.1-jruby --no-ri --no-rdoc

Now start up on the rails project - my project is to simply record my vehicle mileage:
7. jruby -S rails mileage

8. Modify config/database.yml to use derby:
development:
adapter: jdbcderby
database: db/development
timeout: 5000


9. That's it, the rest of the steps are same as for rails. Once the application is ready, it can be run with the following command:
jruby script/server