Ruby on rails 具有Oracle增强适配器连接的Nil类的未定义方法“Match”
我正在使用连接到Oracle 11g数据库,以便在Rails 4应用程序中更轻松地引用Oracle中的数据。到目前为止,我一直在遵循GitHub repo中的说明,看起来我实际上能够连接到我想要的数据库,但每当我去查询Oracle数据库中的任何数据时,我都会遇到以下错误:Ruby on rails 具有Oracle增强适配器连接的Nil类的未定义方法“Match”,ruby-on-rails,oracle,oracle11g,Ruby On Rails,Oracle,Oracle11g,我正在使用连接到Oracle 11g数据库,以便在Rails 4应用程序中更轻松地引用Oracle中的数据。到目前为止,我一直在遵循GitHub repo中的说明,看起来我实际上能够连接到我想要的数据库,但每当我去查询Oracle数据库中的任何数据时,我都会遇到以下错误: NoMethodError: undefined method `match' for nil:NilClass from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/active
NoMethodError: undefined method `match' for nil:NilClass
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:322:in `new_connection'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:389:in `initialize'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:26:in `new'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:26:in `initialize'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced/connection.rb:9:in `new'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced/connection.rb:9:in `create'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-oracle_enhanced-adapter-1.6.3/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:156:in `oracle_enhanced_connection'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from /Users/47900/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
from /Users/47900/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/47900/.rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
我曾尝试用谷歌搜索该问题并检查文档/问题,但没有发现任何有用的东西。我还可以通过sqlplus访问这个数据库,所以我的Oracle即时客户端实际上正在工作。这是我的database.yml和模型,我已经配置并正在使用它来尝试查询Oracle DB:
#database.yml (obviously data is faked)
development:
adapter: oracle_enhanced
host: //127.0.0.1:1527/DATABASE_NAME
username: ENV['USERNAME']
password: ENV['PASSWORD']
#oracle.rb
class Oracle < ActiveRecord::Base
self.table_name = "SCHEMA.TABLE"
self.primary_key = "obj_id"
end
#The queries I have tried through Rails Console
>> Oracle
>> ActiveRecord::Base.connection.execute("SELECT * FROM TABLE WHERE obj_id > 1000000;")
我会不断更新更多的信息,因为我获得它,非常感谢你提前 在database.yml配置文件中缺少数据库。使用中描述的database.yml文件 签出此代码行:302和322 database.yml
development:
adapter: oracle_enhanced
host: 127.0.0.1
port: 1527
database: <DATABASE_NAME>
username: ENV['USERNAME']
password: ENV['PASSWORD']