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: http://www.oracle.com/technology/pub/articles/haefel-oracle-ruby.html.
In fact, you need to:

Download Ruby OCI library from http://rubyforge.org/projects/ruby-oci8

Configure access to Oracle in database.yml


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.

3 Responses to “Ruby on Rails with Oracle”

  1. Gregory Says:

    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. Roman Mackovcak Says:

    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.

  3. Gregory Says:

    I don’t have enough experience either, but here is a comparison between Lucene and Oracle, so it may help:
    http://www.theserverside.com/discussions/thread.tss?thread_id=30666