So you’ve written a Rails app and you want to show it off to your boss at work because you know that it will impress them. Problem is that your company only uses Java and won’t consider it for their production environment if it can’t be deployed under a JVM. Let’s go:
- Install JRuby http://jruby.org
- Install the required gems for Ruby on Rails to work with JRuby
- Install the gems particular to your application
- Update your
database.xmlfile, prefixing your adapter with jdbc - Start your JVM
- Demonstrate
- Sit back and wait for promotion
jgem install mongrel activerecord-jdbcsqlite3-adapter rails
jruby -S rake gems:install
development: adapter: jdbcsqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000
jruby script/server
Some notes on whats going on above:
- Detailed installation instructions for JRuby can be found on their wiki: http://kenai.com/projects/jruby/pages/GettingStarted
- The
jruby -S rakecommand is very important as the-Sswitch ensures that therakecommand is sourced from the JRuby home, not the system path which would contain a native Ruby install - ActiveRecord-JDBC can handle most any database you can think of in a corporate environment. Check it out here: http://kenai.com/projects/activerecord-jdbc/
- If you wish to use another database, there are some gems already pre-packaged, more details on the github page: http://github.com/nicksieger/activerecord-jdbc-adapter