11 Sep 2007 (updated 11 Sep 2007 at 21:47 UTC)
»
warbler is awesome -- it
allows you to _easily_ make Ruby-
on-Rails applications Jruby-ish, and war'd up to deploy in a container. Here
are the instructions for setting this up under JBoss, but except for the last
step, should run under any standard Java web container.
Here's the steps:
1) install jruby
2) install warbler
jruby --command gem install warbler
3) Do config
jruby --command warble config
This creates a file called config/warble.rb which can be used to add
gems and
other configuration goodness.
4) If you're going to use ActiveRecord-jdbc, then following these
instructions:
Download ActiveRecord/JDBC.
Install ActiveRecord-jdbc:
jruby --command gem install /path/to/ActiveRecord-jdbc-0.5.gem
Add this gem to warble.rb:
config.gems << 'ActiveRecord-JDBC'
config.gems << 'jruby-openssl' #not required makes other things
easier
Add the following lines to environment.rb:
if RUBY_PLATFORM =~ /java/
require 'rubygems'
RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end
If you are connecting straight to a PostgreSQL database, you can just
include
the postgres-pr gem in your warble.rb file, and keep your
database.yml file normal. If you are using JDBC, following the
latest tips for that (it seems to change) for configuring
database.yml. If you are using a JNDI connection, then specify it
like this:
production:
adapter: jdbc
jndi: java:putyourjndipathhere
Configuring your datasource in JNDI is up to you :)
5) Warble it
jruby --command warble
5) Deploy it
cp yourfile.war /path/to/jboss/deploy
The only problem I have right now is that on every request it generates
a
warning message about having to close my connection for me. I'm not sure if
that's a warble config thing or a Postgres thing or a JRuby thing or a JDBC
thing.
I hope I didn't leave anything out :)</pre>