JRuby, Postgres & Rails

by tokumine

Just a quickie. When using Rails, Postgres and JRuby for the first time, you’ll need to install a jdbc-friendly database driver. The nice fast ones you’re used to written in C (like ruby-pg), will simply not work.

There seems to be lots of choice here, and dead ends of old attempts. The latest and greatest however is the activerecord-jdbc-adapter and it’s set of prepackaged-adaptors.

So, to use postgres, and are using the fabulous Ruby Version Manager, you would install the postgres adaptor gem like this:

gem install activerecord-jdbcpostgresql-adapter

Then your configure your database.yml

development:
      adapter: jdbcpostgresql
      username: blog
      password:
      hostname: localhost
      database: weblog_development

Job done!

Advertisements