【问题标题】:Cannot detect association_proxy.rb in Rails 4.0.0.rc1在 Rails 4.0.0.rc1 中无法检测到 association_proxy.rb
【发布时间】:2013-06-13 05:21:21
【问题描述】:

我在 Rails 4.0.0.rc1 中使用composite_primary_keys 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>

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

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

【问题讨论】:

    标签: ruby-on-rails-4


    【解决方案1】:

    使用不同也有同样的问题

    gem 'composite_primary_keys', '=3.1.0'
    

    通过修改版本并运行来修复它

    bundle update composite_primary_keys
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 2013-06-04
      • 1970-01-01
      • 1970-01-01
      • 2020-04-03
      相关资源
      最近更新 更多