Problems using Oracle with Rails
So, following a variety of tutorials, I installed the following gems on my windows box:
"activerecord-oracle_enhanced-adapter"
and
"ruby-oci8"
As well as modifying my database.yml to look like:
oracle_development:
adapter: oracle_enhanced
database: 127.0.0.0:1521/sid
username: uid
password: pid
Ruby OCI8 wouldn't compile (the tutorial at: [the rails wiki][1] implied this might be the case, and suggested using version 1.0.4, instead). So, 1.0.4 compiles and installs just fine, but once I have it (and load a oci.dll into Ruby), I run a quick test from the Rails Console and see:
Loading development environment (Rails 2.3.5)
OracleConnector.test RuntimeError: Please install the oracle_enhanced adapter:
gem install activerec ord-oracle_enhanced-adapter
(ERROR: ruby-oci8 version 1.0.7 is too old. Please install ruby-oci8 version 2.0.3 or later.)
I'm not really sure what to do. For one, I DEFINITELY have the "activerecord-oracle_enhanced-adapter", and I'm not sure why it thinks other wise. For two, I have no idea how to get a newer copy of OCI8...when I try, I see:
C:\Documents and Settings\jschultz\workspace\OracleTest>gem install ruby-oci8
Building native extensions. This could take a while...
ERROR: Error installing ruby-oci8:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb
checking for load library path...
PATH...
checking C:\Ruby\bin... y开发者_如何学Goes
C:/Ruby/bin/oci.dll looks like a full client.
checking for cc... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby/bin/ruby
--with-instant-client
--without-instant-client
./oraconf.rb:562:in `check_cc': RuntimeError (RuntimeError)
from ./oraconf.rb:549:in `init'
from ./oraconf.rb:680:in `initialize'
from ./oraconf.rb:345:in `new'
from ./oraconf.rb:345:in `get'
from extconf.rb:18
ng
---------------------------------------------------
Error Message:
C compiler doesn't work correctly.
Backtrace:
./oraconf.rb:562:in `check_cc'
./oraconf.rb:549:in `init'
./oraconf.rb:680:in `initialize'
./oraconf.rb:345:in `new'
./oraconf.rb:345:in `get'
extconf.rb:18
---------------------------------------------------
See:
* http://ruby-oci8.rubyforge.org/en/HowToInstall.html
* http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html
[1]: http://wiki.rubyonrails.org/database-support/oracle
And I have NO idea what to do about that...
for starters you should be using the correct ruby version. Use version 1.8.7 or 1.9.1 from rubyinstaller.org. Then make sure to install the development kit.
Once you have that, you can just run gem install ruby-oci8
and it will work. The development kit will allow to make native builds.
I think, I am bit late but I found a good tutorials for this...
Oracle Articles: connect rails with oracle
Rails on Oracle: Part 1 - Setting up Rails to connect to an Oracle database
Rails on Oracle: Part 2 - Setting up Rails to connect to an Oracle database
Cheers!
精彩评论