Satya's blog - Rails and Oracle

Feb 22 2010 20:16 Rails and Oracle

Getting Rails to work with Oracle is straight-forward. Get the instant client libraries from Oracle. I got the following, and unzipped them into /opt/oracle/instantclient-VERSION:

for n in instantclient*.zip; do unzip $n; done

Symlink the directory so that we don't have to refer to it by version number, and then symlink certain files inside it because the libraries are supposed to be generically-named:

ln -s instantclient-VERSION instantclient
cd instantclient
ln -s
ln -s

In /etc/apache2/envvars add:

export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH

And then install the ruby-oci8 driver, and the activerecord_oracle_adapter:

sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH /usr/bin/gem install ruby-oci8 --version "< 2.0.0"
sudo gem install activerecord-oracle-adapter

Here's an example config/database.yml file:

  adapter: oracle
  username: foo
  password: boo

There, all done. There might be a way to do this using ODBC but I'm just happy this works pain-free (unlike sybase).

Tag: rails