2013-04-13 2 views
0

나는이 오류가있어 작업을 실행하면이 내 Rakefile정의되지 않은 메서드`alias_method_chain '

require 'bundler' 
Bundler.setup 
require 'active_record' 
require 'sqlite3' 
require 'yaml' 
require 'logger' 

task :migrate => :environment do 
    ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil) 
end 

task :environment do 
    ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yaml'))['development']) 
    ActiveRecord::Base.logger = Logger.new(STDOUT) 
end 

입니다 :

rake aborted! 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:2449: warning: already initialized constant Class::VALID_FIND_OPTIONS 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:2449: warning: previous definition of VALID_FIND_OPTIONS was here 
undefined method `alias_method_chain' for #<Class:0x00000001606340> 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:2002:in `method_missing' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/validations.rb:387:in `block in included' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/validations.rb:386:in `class_eval' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/validations.rb:386:in `included' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:3210:in `include' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:3210:in `block in <module:ActiveRecord>' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:3208:in `class_eval' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:3208:in `<module:ActiveRecord>' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-2.3.18/lib/active_record/base.rb:5:in `<top (required)>' 
/home/marco/desenv/technical_analysis/Rakefile:14:in `block in <top (required)>' 
/usr/local/rvm/gems/[email protected]/gems/rake-10.0.4/lib/rake/task.rb:246:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute' 

이 좀 디버깅을했고 일부 테스트 ... 그런 다음 활성 레코드 3.2303 버전으로 이동했으며 모두 예상대로 작동했습니다. 3.2.18 버전에 대한 문서를 찾지 못했습니다 ...

3.2.13 버전을 사용해도 상관 없지만, 궁금합니다.

답변

3

우선, 3.2.18이 아닌 ActiveRecord 2.3.18을 사용하고 있습니다. (내 지식에는 후자가 존재하지 않습니다). ActiveRecord 2.3은 꽤 오래된 버전으로 바뀌고 있습니다. 사용하고있는 Ruby 2.0과 호환되지 않는다고 생각합니다.

하지만 중심 문제는 in Rails 2.2-2.3, alias_method_chainActiveSupport 모듈로 이동하여 3.0의 Module으로 다시 이동했다는 것입니다. 귀하는 귀하의 업무에 ActiveSupport을 포함시키지 않았으며 이것이 그 문제의 원인이라고 생각합니다.

빠른 픽스는 require "active_support" 일 것입니다.

+0

비슷한 문제가 있습니다. ('undefined method 'alias_method_chain', 루비 1.8.7과 레일 2.3.8). 나는'alias_method_chain'을 인터프리터에서 작동하도록 시도했다. 처음에는'require "rubygems"와'require "active_support"를 사용했으나 성공하지 못했다. 여전히'undefined method'이다. 'ActiveSupport.alias_method_chain : test1, : test2' 시도가 여전히'test1'과'test2'라는 간단한 방법으로 실패했지만, 'ActiveSupport' 모듈에 대해'test1_with_test2 '가 정의되지 않은 다른 오류를 발생시킵니다. – Erhannis