1

我正在使用composite_primary_keys带有 Rails 4.0.0.rc1 的 gem。添加到 Gemfile 后

gem 'composite_primary_keys'

并运行捆绑安装,我添加

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>

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

相对于 Rails 加载顺序,我是否在错误的时间需要这个 gem?还是因为 Association_proxy.rb 不再在 Rails 4 中?

4

1 回答 1

6

使用差异有同样的问题

gem 'composite_primary_keys', '=3.1.0'

通过刮擦版本并运行来修复它

bundle update composite_primary_keys

尝试不同的版本可能会有所帮助。

于 2013-06-19T19:01:36.867 回答