Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.
« Payton Jordan Cardin... | Main | Running at Rails... »

http://blogs.sun.com/arungupta/date/20090504 Monday May 04, 2009

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


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

del.icio.us | furl | simpy | slashdot | technorati | digg |
|
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
« Payton Jordan Cardin... | Main | Running at Rails... »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.