Rails application with Oracle Database


Connect your Rails application with Oracle Database

Once I have faced a challenge to connect the rails application with Oracle database. So for the connection with Oracle database i have to spend some time, finally by the following steps i have succeeded.


System with Ubuntu 12.0.4LTS , 64-bit processor and sudo password along with Rails.

Steps to establish connection between Rails application and Oracle database.

Step 1: Download Oracle rpms

Download the following 3 oracle rpm packages from the “link” and place all  rpm packages in a folder.

i) oracle-instantclient12.1-basic-

ii) oracle-instantclient12.1-sqlplus-

iii) oracle-instantclient12.1-devel-

Step 2 : Install alien on your distribution.

[email protected]:~$  sudo apt-get install alien

Step 3:  Install all three rpm packages using alien command

go to your download directory and list the available rpm packages.

i] Install Instant Client sqlplus package :-
[email protected]:~/bak$ sudo alien -i oracle-instantclient12.1-sqlplus-
ii] Install Instant Client Basic Package :-
[email protected]:~/bak$ sudo alien -i oracle-instantclient12.1-basic-
iii] Install Instant Client SDK Package :-
[email protected]:~/bak$ sudo alien -i oracle-instantclient12.1-devel-

Step 4: Install shared object file libaio1 using the usual apt-get command

 [email protected]:~/bak$ sudo apt-get install libaio1

Step 5: Provide libraries path in oracle.conf

[email protected]:~/bak$ sudo vi /etc/ld.so.conf.d/oracle.conf
• /usr/lib/oracle/12.1/client/lib

Step 6: Update the information of all the shared libraries on your system

[email protected]:~/bak$ sudo ldconfig

Step 7: Provide these paths in /etc/bash.bash.rc file


export PATH=$PATH:/usr/lib/oracle/12.1/client64/bin

export ORACLE_HOME=/usr/lib/oracle/12.1/client64

Step 8: Reload your bash file

[email protected]:~/bak$ source ~/.bashrc

Step 9: Now all things are set in your system to connect with oracle database

[email protected]:~/bak$ sqlplus username/[email protected]//ip_address/sid

Note:- where sid = XE

SQL*Plus: Release Production on Wed Sep 4 17:16:41 2013

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Express Edition Release – Production


Above SQL prompt show you have successfully connected to oracle database.

Step 10: To connect your rails application with Oracle Database do the following things

a) Mention these two gems in the gem file

gem ‘ruby-oci8′, ‘~>2.1.5′

gem ‘activerecord-oracle_enhanced-adapter’, :git => ‘git://github.com/rsim/oracle-enhanced.git’

and do “bundle install”

b) configure database.yml file like this

Note:- where sid =XE


adapter: oracle_enhanced

database: ip_address/sid

# port: 1521

username: XXXXXX

password: XXXXXX

Now run your Rails application which is connected with Oracle Database.

Thanks to Oracle for the wonderful Database.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation

Innovabe Menu