代码之家  ›  专栏  ›  技术社区  ›  Mateusz Urbański

轨道4.1.2无法安装子弹宝石

  •  2
  • Mateusz Urbański  · 技术社区  · 10 年前

    我已添加到我的宝石文件子弹宝石:

    gem "bullet", :group => "development"
    

    在我的发展中,我补充道:

      config.after_initialize do
        Bullet.enable = true
        Bullet.alert = true
      end
    

    当我尝试运行rails服务器时,出现以下错误消息:

    /home/mateusz/.rvm/gems/ruby-2.0.0-p0@rails4/gems/bullet-4.7.1/lib/bullet/active_record4.rb:53:in `alias_method': undefined method `construct_association' for class `ActiveRecord::Associations::JoinDependency' (NameError)
    

    提前感谢您的帮助。

    1 回复  |  直到 10 年前
        1
  •  4
  •   zhirzh Mc As    10 年前

    嗯。。我做得很好。尝试过一个已有的和新的项目-Win&林,两个。可能还有其他问题 gem 版本或 rails 版本

    只是为了一个测试用例——为什么不创建一个新的测试项目,看看它在那里是否有效

    rails new testproj
    cd testproj
    rails generate scaffold Person name:string
    rake db:create db:migrate
    

    完成后,打开 gemfile 并添加: gem "bullet", :group => "development"
    然后在 testproj/config/environments/development.rb 文件,添加此

    Rails.application.configure do
      ...
      config.after_initialize do
        Bullet.enable = true
        Bullet.alert = true
      end
      ...
    end
    

    一旦完成,就做 bundle install 然后开始 rails server

    如果仍然出现错误,请更新gems:-
    gem update --system 然后 gem update