之前我有这个工作(ish),但显然我的系统发生了一些变化,它已经不再有效了。我正在拾取某些旧的Rails 2.1项目的片段,当我去做任何事情时,我得到同样的神秘错误:
$ rake db:migrate --trace
(in /Users/ry/Documents/rails/yogatoday)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `class_attribute' for ActiveRecord::Base:Class
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/base.rb:1672:in `method_missing_without_paginate'
/opt/local/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.2.3/lib/will_paginate/finder.rb:164:in `method_missing'
/opt/local/lib/ruby/gems/1.8/gems/paperclip-2.3.15/lib/paperclip.rb:182:in `included'
/opt/local/lib/ruby/gems/1.8/gems/paperclip-2.3.15/lib/paperclip/railtie.rb:20:in `include'
/opt/local/lib/ruby/gems/1.8/gems/paperclip-2.3.15/lib/paperclip/railtie.rb:20:in `send'
/opt/local/lib/ruby/gems/1.8/gems/paperclip-2.3.15/lib/paperclip/railtie.rb:20:in `insert'
/opt/local/lib/ruby/gems/1.8/gems/paperclip-2.3.15/rails/init.rb:2:in `evaluate_init_rb'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/rails/plugin.rb:95:in `evaluate_init_rb'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/rails/plugin.rb:91:in `evaluate_init_rb'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/rails/plugin.rb:44:in `load'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/rails/plugin/loader.rb:33:in `load_plugins'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/rails/plugin/loader.rb:32:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/rails/plugin/loader.rb:32:in `load_plugins'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:292:in `load_plugins'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:142:in `process'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `send'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `run'
/Users/ry/Documents/rails/yogatoday/config/environment.rb:13
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/tasks/misc.rake:3
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/local/bin/rake:19:in `load'
/opt/local/bin/rake:19
如果我然后查看我的config / environment.rb文件:
Rails::Initializer.run do |config|
config.gem 'aasm', :version => '2.1.5'
config.gem 'brightcove-api', :version => '1.0.2'
config.gem 'fakeweb', :version => '1.2.8'
config.gem 'httparty', :version => '0.5.2'
config.gem 'calendar_date_select', :version => '1.15'
config.gem 'exceptional'
config.gem 'fastercsv', :version => '1.4'
config.gem 'hominid', :version => '2.1.5'
config.gem 'lockfile', :version => '1.4.3'
config.gem 'mislav-will_paginate', :lib => 'will_paginate', :version => '~> 2.2.3', :source => 'http://gems.github.com'
config.gem 'paperclip'
config.gem 'hashie'
config.gem 'rest-client', :lib => 'rest_client', :version => '0.8.2'
...
end
第13行是Rails::Initializer.run do |config|
行。
我更像是一个rails 3,所以我不确定这里发生了什么,但它似乎是某种版本冲突。有关如何运行的任何建议吗?
谢谢!
答案 0 :(得分:1)
我得到了同样的错误。
我认为这是paperclip
和will_paginate
之间的冲突。
请尝试使用paperclip版本2.3.0
我尝试了它并修复了问题。
答案 1 :(得分:1)
新版纸夹会导致此错误。在issue中对此进行了解释,最近添加了pull request来修复此错误。
您有两种选择:在本地gem上应用补丁,或者回滚到以前版本的回形针。
您应在config/environment.rb
中声明一个明确的版本。