【问题标题】:Error already initialized constant Activerecord::base::OrmAdapter错误已初始化常量 Activerecord::base::OrmAdapter
【发布时间】:2016-02-04 23:44:50
【问题描述】:

我正在尝试在 Heroku 上的 Rails 应用程序中运行脱轨的 gem,因为我遇到了 r14 内存问题。

我有一个爱好帐户,使用 Puma 作为我的服务器,只运行 1 dyno。

我遇到的问题是,当我尝试运行任何出轨的 gem 时,perf exec: 方法会出轨。我遇到了这个问题

Booting: production
/Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/orm_adapter-0.5.0/lib/orm_adapter/adapters/active_record.rb:81: warning: already initialized constant ActiveRecord::Base::OrmAdapter
/Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/orm_adapter-0.5.0/lib/orm_adapter/adapters/active_record.rb:81: warning: previous definition of OrmAdapter was here
/Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/orm_adapter-0.5.0/lib/orm_adapter/adapters/active_record.rb:81: warning: already initialized constant ActiveRecord::Base::OrmAdapter
/Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/orm_adapter-0.5.0/lib/orm_adapter/adapters/active_record.rb:81: warning: previous definition of OrmAdapter was here
/Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/connection_specification.rb:171:in `spec': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:50:in `establish_connection'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:44:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/base.rb:316:in `<module:ActiveRecord>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-4.2.1/lib/active_record/base.rb:26:in `<top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/devise-3.5.2/lib/devise/orm/active_record.rb:3:in `<top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
    from /Users/yihuazhang/Projects/learnabli/formula/config/initializers/devise.rb:24:in `block in <top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/devise-3.5.2/lib/devise.rb:278:in `setup'
    from /Users/yihuazhang/Projects/learnabli/formula/config/initializers/devise.rb:3:in `<top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:652:in `block in load_config_initializer'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:166:in `instrument'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:651:in `load_config_initializer'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:615:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/engine.rb:615:in `block in <class:Engine>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:420:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:419:in `block in each_strongly_connected_component_from'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:413:in `call'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:413:in `each_strongly_connected_component_from'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `call'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/derailed_benchmarks-1.3.0/lib/derailed_benchmarks/tasks.rb:26:in `block (2 levels) in <top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/derailed_benchmarks-1.3.0/lib/derailed_benchmarks/tasks.rb:60:in `block (2 levels) in <top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:199:in `each'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/derailed_benchmarks-1.3.0/bin/derailed:41:in `exec'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/derailed_benchmarks-1.3.0/bin/derailed:92:in `<top (required)>'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/bin/derailed:23:in `load'
    from /Users/yihuazhang/.rbenv/versions/2.2.2/bin/derailed:23:in `<main>'

但我真的不知道该怎么解决这个问题。

【问题讨论】:

  • 欢迎来到 Stack Overflow。请阅读“How to Ask”,包括底部的链接。我们需要您格式化您的问题以提高可读性,因为您的努力可以帮助我们帮助您。

标签: ruby-on-rails ruby ruby-on-rails-4 activerecord rails-activerecord


【解决方案1】:

在 Rails 根目录中运行 rake rails:update 并重新启动服务器。

【讨论】:

    【解决方案2】:

    在连接时未指定适配器(或配置文件 config/database.yml 缺少适配器字段)时引发。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 2023-01-13
      • 1970-01-01
      • 2013-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多