无法在Rails 4.0.0.rc1中检测association_proxy.rb

时间:2013-06-13 05:21:21

标签: ruby-on-rails-4

我在Rails 4.0.0.rc1中使用composite_primary_keys gem。添加到Gemfile后

gem 'composite_primary_keys'

并运行bundle install,我添加

require 'composite_primary_keys'

application.rb。但是,当我运行rails generate create_table时,我收到以下错误:

  /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `require': 
 cannot load such file -- active_record/associations/association_proxy.rb (LoadError)
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `block in require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/composite_primary_keys-3.1.6/lib/composite_primary_keys.rb:37:in `<top (required)>'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/name/idme/config/application.rb:6:in `<top (required)>'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0.rc1/lib/rails/commands.rb:46:in `require'
    from /Users/name/.rvm/gems/ruby-1.9.3-p385/gems/railties-4.0.0.rc1/lib/rails/commands.rb:46:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>

我检查了此gem中的composite_primary_keys.rb文件,发现它需要association_proxy.rb。但是,似乎Rails找不到这个文件。

我是否在Rails装载订单的错误时间需要此宝石?或者这是因为association_proxy.rb不再在Rails 4中了?

1 个答案:

答案 0 :(得分:6)

与使用

的区别有同样的问题
gem 'composite_primary_keys', '=3.1.0'

通过抓取版本并运行

来修复它
bundle update composite_primary_keys

尝试使用其他版本可能有所帮助。