Alex Rivera | Logout

How to configure Ruby on Rails with Oracle?

Asked 2009-04-19T05:28:31.153
15

There's several pages on the web that discuss this, but most are out of date or inaccurate in some way.

What's the scoop?

Edit
Report

1 Answer

38

Build ruby, gem, and rails

as per http://rubyonrails.org/download:

build ruby
build gem
use gem to install rails

Get Oracle Instantclient

Download from https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html

You need these two packages for your architecture.

instantclient-basic
instantclient-sdk

Unzip these files, and make this link

cd instantclient_10_2
# .dylib for mac, .so for linux
ln -s libclntsh.dylib.10.1 libclntsh.dylib

Build ruby-oci8

Note, JRuby users don't need ruby-oci8, but do need the Oracle JDBC jar, either ojdbc6.jar or ojdbc5.jar depending on whether you have Java 6 or Java 5.

Download from http://ruby-oci8.rubyforge.org/en/index.html and run

# DYLD for mac
export DYLD_LIBRARY_PATH=/path/to/instantclient_10_2
# LD for linux
export LD_LIBRARY_PATH=/path/to/instantclient_10_2
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Test with this line and your database connection string.

ruby -r oci8 -e "OCI8.new('scott/tiger@orcl').exec('select * from user_tables') do |r| puts r.join(','); end"

Install activerecord-oracle_enhanced-adapter

Note, not activrecord-oracle-adapter as many older pages mention.

gem install activerecord-oracle_enhanced-adapter

Do that sweet rails thing
answered 2009-04-19T05:50:08.653

Your Answer