Ruby on Rails with Oracle

I am working on a prototype in an big company and they do store data in Oracle. It took me some time to set up RoR working with Oracle. So, here are the things you need to do.

First of all, there is a great tutorial on Oracle site:
In fact, you need to:
Download Ruby OCI library from
Configure access to Oracle in database.yml

  adapter: oci
  username: your_username
  password: your_password
  host: HOST_NAME

Create a sequencer for each table (rails uses it to generate id). The sequencer must follow naming convention (see script below). You can create one using:


Since I am using one of the non-english character sets and the Oracle instance uses ISO 8859-2 and it is not compatible with Windows code page, I had problems with encoding. To avoid it, it is necessary to set up variable NLS_LANG. I did it in environment.rb.


Now you should be able to access the data source, perform basic operations with data, and see the data correctly.


  1. Some time ago you’ve made a great comparison between full text search using MySQL and Ferret. It would be very helpful to add Oracle to that comparison.

  2. Unfortunately I do not have enough experience with Oracle full text search. If you have the experience, do not hesitate and describe it. I will add a link to your article.

Comments are closed.