Anton Jenkins | March 26, 2009
Ok, so this post is a bit earlier than advertised, but it’s better than being late! Following up from Rails on Oracle: Part 1 – Installing the oracle instant client on Mac OS X, now we are going to get rails to use our freshly installed oracle client…
Step 1: Download ruby-oci8
Step 2: Make and install ruby-oci8
If you’ve followed the instructions from part 1 then you should have your oracle instant client installed in
/opt/oracle/instantclient. If you’ve not installed the instant client yet then scoot off to part 1 and perform those steps before going any further. If you’ve installed it somewhere different then you will need to amend the following commands where appropriate:
1 2 3 4 5 6 7
cd ~/Downloads tar xvzf ruby-oci8-1.0.5.tar.gz cd ruby-oci8-1.0.5 ruby setup.rb config -- --with-instant-client=/opt/oracle/instantclient make sudo make install
Step 3: Install the oracle_enhanced adapter
sudo gem install activerecord-oracle_enhanced-adapter
Step 4: Configure you rails project to use an oracle database
Lets say with have the same oracle database as we had in part 1 which looked like so:
- Host : myserver
- domain : mydomain.com
- Port : 1521
- SID : mydatabase
- Service : mydatabase.mydomain.com
We’d express this in our
database.yml file with the following entry:
1 2 3 4 5
development: adapter: oracle_enhanced database: myserver:1521/mydatabase.mydomain.com username: myusername password: mypassword
Step 5: Profit!
Now (fingers crossed!) you should be ready. It’s been tricky for me to test this thoroughly because I don’t have access to a clean mac to start from scratch with. My mac is already set up and ready to go so it’s possible I could have missed something. If you have problems then leave a comment and I’ll try my best to sort you out and and update the instructions.
Looking for part 1?
Part 1 : Instructions on how to install the Oracle instant client on OS X and test it with sqlplus.