Friday, April 17, 2009

Building Ruby on Rails with Oracle Instantclient

- build ruby, gem, rails as per http://rubyonrails.org/download
build ruby
build gem
use gem to install rails
- get instantclient
instantclient-basic
instantclient-sdk

note: build against this, ok to run against the .so's in /usr/lib
- on mac, make this link
cd .../instantclient_10_2
ln -s libclntsh.dylib.10.1 libclntsh.dylib
- build ruby-oci8 from http://ruby-oci8.rubyforge.org/en/index.html
export DYLD_LIBRARY_PATH=.../instantclient_10_2
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
- test (this is on one line)
ruby -r oci8 -e "OCI8.new('nm/pass@db').exec('select * from user_tables') do |r| puts r.join(','); end"
- Install the activerecord-oracle_enhanced-adapter gem, NOT, as many pages out-of-dately specify, activerecord-oracle-adapter
gem install activerecord-oracle_enhanced-adapter
config/database.yml:
development:
adapter: oracle_enhanced
database: orcl # or, host:
username: scott
password: tiger
- do that sweet rails thing:
rails mhtest
cd mhtest
ruby script/generate scaffold comic title:string issue:integer publisher:string
rake db:migrate
ruby script/server
- hooray, it works
http://localhost:3000/comics
- references:

http://emphaticsolutions.com/2008/05/22/connecting-to-oracle-from-ruby-on-rails.html
http://www.oracle.com/technology/pub/articles/saternos-ror-faq.html
http://drawohara.com/post/37166893/rails-unsucking-oci-oracle-on-rails-2-1
http://www.oracle.com/technology/pub/articles/haefel-oracle-ruby.html