1. Install JRuby and Rails
-
Download JRuby from http://dist.codehaus.org/jruby/
$ wget http://dist.codehaus.org/jruby/jruby-bin-1.0.1.zip -
Unzip JRuby to your favorite directory (e.g. /usr/local).
$ cd /usr/local
$ sudo unzip ~/jruby-bin-1.0.1.zip -
Set environment variable JRUBY_HOME to point JRuby directory.
$ export JRUBY_HOME=/usr/local/jruby-1.0.1
$ export PATH=$PATH:$JRUBY_HOME/bin -
Install rails from command line.
$ jruby -S gem install rails -y --no-ri --nor-rdoc
2. Prepare Rails App
-
Generate Rails application to yoru favorite directory.
$ jruby -S rails my-app -
Install dependency libraries to your Rails dir.
$ jruby -S rake rails:freeze:gems
3. Setup JRuby on Rails with Grizzly
-
Download and unzip JRuby on Rails with Grizzly.
$ wget http://download.java.net/maven/2/com/sun/grizzly/bundles/grizzly-jruby-webserver-1.6.0.zip
$ unzip grizzly-jruby-webserver-1.6.0.zip
-
Run grizzly server.
$ cd grizzly-jruby-webserver-1.6.0
$ java -Xmx512m -server -Djruby.jit.enabled=true -Djruby.objectspace.enabled=false -jar jruby-1.6.0.jar -n 3 ~/my-app
FAQ
Q: I got "no implicit conversion from nil to integer (TypeError)". Why?
A: You may forget "rake rails:freeze:gems" in your Rails directory.