使用Oracle和Rails的问题

所以,按照各种教程,我在我的Windows框中安装了以下gem:

"activerecord-oracle_enhanced-adapter" 

 "ruby-oci8" 

以及修改我的database.yml看起来像:

 oracle_development: adapter: oracle_enhanced database: 127.0.0.0:1521/sid username: uid password: pid 

Ruby OCI8无法编译(教程:[the rails wiki] [1]暗示可能就是这种情况,建议使用1.0.4版本)。 所以,1.0.4编译和安装就好了,但是一旦我拥有它(并将一个oci.dll加载到Ruby中),我从Rails控制台运行一个快速测试,看看:

 Loading development environment (Rails 2.3.5) 

OracleConnector.test RuntimeError:请安装oracle_enhanced适配器: gem install activerec ord-oracle_enhanced-adapter (错误:ruby-oci8版本1.0.7太旧。请安装ruby-oci8版本2.0.3或更高版本。)

我不确定该怎么做。 首先,我肯定有“activerecord-oracle_enhanced-adapter”,我不确定为什么它认为其他明智的。 对于两个,我不知道如何获得更新的OCI8 …当我尝试时,我看到:

 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... yes 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 

我不知道该怎么办……

对于初学者,你应该使用正确的ruby版本。 使用rubyinstaller.org中的1.8.7或1.9.1版。 然后确保安装开发套件。

一旦你有了,你可以运行gem install ruby-oci8 ,它会工作。 开发工具包将允许进行本机构建。

我想,我有点迟了但是我找到了一个很好的教程…

Oracle文章:使用oracle连接rails

Oracle上的Rails:第1部分 – 设置Rails以连接到Oracle数据库

Oracle上的Rails:第2部分 – 设置Rails以连接到Oracle数据库

干杯!