Miles to go …

May 4, 2009

TOTD #81: How to configure “database.yml” to be used with both JRuby and MRI ?

Filed under: General — arungupta @ 9:57 am

In JRuby-on-Rails tutorial at Rails Conf 2009, Nick Sieger shared a nice little tip on how to configure “database.yml” to be usable with both JRuby and MRI:

<% jdbc = defined?(JRUBY_VERSION) ? ‘jdbc’ : ” %>
development:
  adapter: <%= jdbc %>mysql
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock
# …

“JRUBY_VERSION” is defined only if your using JRuby and so the right database adapter is picked up accordingly.

The complete slides for the tutorial are available here. Learn about other related talks here.

Please leave suggestions on other TOTD (Tip Of The Day) that you’d like to see. An archive of all the tips is available here.

Technorati: conf railsconf lasvegas tutorial jruby ruby rubyonrails

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. TOTD #35: Rails Database Connection on Solaris
  2. TOTD #26: Overriding Database Defaults in Rails 2.0.2
  3. TOTD #3: Using JavaDB with JRuby on Rails
  4. ActiveRecord-JDBC 0.5 – simplified database configuration
  5. Database-enabled RoR WAR on GlassFish

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress