我正在尝试使用' activerecord'连接到Oracle数据库。和Ruby 1.8.7并在我的Windows 7机器上得到以下错误。我四处寻找这个问题并且遇到了1.8和1.9 ruby声明' Hash'但是我使用Ruby 1.8.7并且我觉得我使用了正确的哈希声明,如果我错了请纠正我。
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require': C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-oracle_enhancedadapter-1.5.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:917: odd number list for Hash (SyntaxError)
read_committed: "READ COMMITTED",
^
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.5.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:917: syntax error, unexpected ':', expecting '}'
read_committed: "READ COMMITTED",
^
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.5.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:917: syntax error, unexpected ',', expecting kEND
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.5.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:919: syntax error, unexpected '}', expecting kEND
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.5.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1471: dynamic constant assignment
DBMS_OUTPUT_BUFFER_SIZE = 10000 # can be 1-1000000
^
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.5.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1555: syntax error, unexpected $end, expecting kEND
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `establish_connection'
from oracle_conn_testing.rb:5
这就是我的代码的样子
require 'rubygems'
gem "activerecord-oracle_enhanced-adapter"
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "oracle_enhanced",
:database => "someurl.net:1523/ABCAD",
:username => "testing1",
:password => "testing1")
class TestTable < ActiveRecord::Base
set_table_name "TABLE_NAME"
set_primary_key "ID"
end
TestTable.find(:all).each do |tt|
p tt
end
nac = TestTable.new()
其他信息: 我的机器上有宝石: *本地宝石*
我在 Rubygems版本 :
下面使用C:\ Users \ tester1&gt; gem -v
1.4.2
我尝试使用 OCI8 进行连接,并且我能够从Oracle数据库中获得响应,因此我的计算机没有连接问题。
irb(main):006:0> OCI8.new('testing1', 'testing1', 'someurl.net:1523/ABCAD').exec('select sysdate from dual') do |r| puts r.join(', ') end
Mon Mar 10 15:09:23 -0400 2014
=> 1
我使用下面的链接作为我的参考: http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/oow10/rubyhol/instructions/rubyrails.htm
答案 0 :(得分:2)
错误消息显示您的错误来自activerecord-oracle_enhancedadapter gem内部,并且该gem具有Ruby 1.9样式哈希。您可能会发现该gem的旧版本支持Ruby 1.8并切换到该版本。