类'ActiveRecord :: Base'的未定义方法`arel_attributes_values'

时间:2013-07-17 19:25:15

标签: ruby-on-rails ruby ruby-on-rails-4

当我尝试运行时

$ rails console

我收到以下错误

/usr/local/lib/ruby/gems/2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `arel_attributes_values' for class `ActiveRecord::Base' (NameError)

............. 其他错误跟随......只是追溯

我的版本如下

$ gem -v
2.0.5
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41647) [x86_64-linux]
$ rails -v
Rails 4.0.0
$ rvm -v 
rvm 1.21.11 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
$ uname -a
Linux cdv-web01 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

我是否必须安装一个我不知道的宝石?

更新:包括整个追溯......

Warning: NLS_LANG is not set. fallback to US7ASCII.
/home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `arel_attributes_values' for class `ActiveRecord::Base' (NameError)
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method_chain'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:116:in `<class:Base>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:2:in `<module:ActiveRecord>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb:1:in `<top (required)>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:211:in `block in load_dependency'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:211:in `load_dependency'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:38:in `<top (required)>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:211:in `block in load_dependency'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:211:in `load_dependency'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-oracle_enhanced-adapter-1.4.2/lib/activerecord-oracle_enhanced-adapter.rb:12:in `block in <class:OracleEnhancedRailtie>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/base.rb:322:in `<module:ActiveRecord>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/base.rb:22:in `<top (required)>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/maintenance_scheduler/app/models/cmts_device.rb:1:in `<top (required)>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `load'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `block in load_file'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:in `load_file'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in `require_or_load'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
        from /home/aayerd200/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/maintenance_scheduler/config/environment.rb:7:in `<top (required)>'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:189:in `require'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
        from /home/aayerd200/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:63:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

使用ReadyForRails4 ......

输入为......

source 'http://rubygems.org'

gem 'rails', '4.0.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'activerecord-oracle_enhanced-adapter'
gem 'ruby-oci8'
gem 'mysql2'
gem 'prototype-rails'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
#   gem 'webrat'
# end

enter image description here

2 个答案:

答案 0 :(得分:7)

似乎gem activerecord-oracle_enhanced-adapter与Rails 4不兼容。

这是应该使用该方法的文件arel_attributes_value

  

http://github.com/rails/rails/blob/master/activerecord/lib/ ...

这是3.2-stable分支的文件。

  

http://github.com/rails/rails/blob/3-2-stable/activerecord/lib/ ...

该方法位于第二个文件(3.2-stable),但它不在第一个文件(master)中。所以它可能在Rails 4中删除了。

如果我是你,我现在只需要恢复到3.2,但是如果你想使用Rails 4,似乎有一个Rails 4的分支。

所以你去你的Gemfile并改变行

  

gem'activerecord-oracle_enhanced-adapter'

  

gem'activerecord-oracle_enhanced-adapter',github:'rsim / oracle-enhanced',branch:'rails4'

bundle update。这应该做到。

答案 1 :(得分:0)

activerecord-oracle_enhanced-adapter gem的更新版本支持Rails 4。

将此添加到您的gem文件

gem "activerecord-oracle_enhanced-adapter", "~> 1.5.0"

这适用于我的Rails 4.0.2

希望这有帮助。

PS:这是宝石的github link