- Get the Ruby OCI8 driver.Â Download the file that ends with “mswin32.rb” and install like this:
E:\ruby>ruby ruby-oci8-1.0.3-mswin32.rb Copy OCI8.rb to e:/ruby/lib/ruby/site_ruby/1.8/DBD/OCI8 Copy oci8.rb to e:/ruby/lib/ruby/site_ruby/1.8 Copy oci8lib.so to e:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt OK? Enter Yes/No: Yes Copying OCI8.rb to e:/ruby/lib/ruby/site_ruby/1.8/DBD/OCI8 ... done Copying oci8.rb to e:/ruby/lib/ruby/site_ruby/1.8 ... done Copying oci8lib.so to e:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt ... done OK
You can test the driver by running a query using Ruby.
E:\>ruby -r oci8 -e "OCI8.new('foo','12345','sid').exec( 'SELECT * from users') do |r| puts r.join(' | ') ; end"
- Install the ActiveRecord Oracle adapter.gem
E:\ruby>install activerecord-oracle-adapter --source http://gems.rubyonrails.org
- Update config/database.yml to connect to Oracle
development: adapter: oracle database: sid username: foo password: 12345 timeout: 5000
- Test by doing a rake db:migrate.
- Test by running the Ruby on Rails server and making sure there are no errors upon startup.
This article is based on these articles.
- Oracle in Ruby on Rails
- Ruby on Rails with Oracle FAQ
- Connecting Ruby on Rails to Oracle on an Intel Mac in Leopard (Mac OSX 10.5)
Pingback: betweenGo » rake db:migrate hangs