Translations of this page?:

Oracle

Using Oracle with Rails

Creating a new application

To create a new Rails application that uses the Oracle adapter:

$ rails -d oracle my_rails_app

Next, edit config/database.yml with the proper settings.

database.yml example

development:
  adapter: oracle
  username: scott
  password: tiger
  database: database_name
  timeout: 5000

For server-side database instances, there appears as of ActiveRecord 2.2.2 and possibly earlier versions, to be a problem using aliases defined in tnsnames.ora. It may be easier to define the database address more explicitly, e.g:

database: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=<host 
  address>)(Port=<port>)))(CONNECT_DATA=(SERVICE_NAME=<service name>)))

Installation

Installing Oracle 10g Express Edition

To install a local instance of Oracle for development and possibly testing, download and run the Oracle 10g Express Edition installer as appropriate for your operating system environment.

Install the ActiveRecord Oracle adapter

Windows

$ gem install activerecord-oracle-adapter --source http://gems.rubyonrails.org

Mac OSX, Linux

$ sudo gem install activerecord-oracle-adapter --source http://gems.rubyonrails.org

oracle_adapter.rb should be copied to \lib\active_record\connection_adapters within the ActiveRecord gem directory

The activerecord-oracle-adapter does not appear to be under active development at this time. An alternative adapter for Oracle is the oracle-enhanced adapter. To install the enhanced adapter do the following:

$ sudo gem install activerecord-oracle_enhanced-adapter

Install the ruby-oci8 gem

Windows

$ gem install ruby-oci8 -v 1.0.4

Mac OSX, Linux

$ sudo gem install ruby-oci8 -v 1.0.4

Rails 2.3 does not work with ruby-oci8 2.0.0

 
database-support/oracle.txt · Last modified: 2009/09/16 16:12 by nss
 
Recent changes RSS feed Creative Commons License