Error connect to MongoID. The application encountered the following error: 'production' database is not configured

Error connect to MongoID. The application encountered the following error: 'production' database is not configured

我刚遇到一个关于 Mongoid 的奇怪问题。我不知道这是属于的错误。 我正在使用:

容器运行后,我访问页面,出现错误。服务器似乎无法读取文件 config/mongoid.yml 中的配置。这是错误

App 55 output: /home/app/dashboard-api/app/controllers/api/v1/from_dashboard_controller.rb:30: warning: found = in conditional, should be ==
App 387 output: Error: The application encountered the following error: 'production' database is not configured. Available: [] (ActiveRecord::AdapterNotSpecified)
App 387 output:     /home/app/dashboard-api/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection'
App 387 output:     /home/app/dashboard-api/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_adapters/connection_specification.rb:211:in `resolve_connection'
App 387 output:     /home/app/dashboard-api/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve'
App 387 output:     /home/app/dashboard-api/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_adapters/connection_specification.rb:169:in `spec'
App 387 output:     /home/app/dashboard-api/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_handling.rb:50:in `establish_connection'
App 387 output:     /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:320:in `before_handling_requests'
App 387 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:159:in `block in negotiate_spawn_command'
App 387 output:     /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:378:in `run_block_and_record_step_progress'
App 387 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:158:in `negotiate_spawn_command'
App 387 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:211:in `<module:App>'
App 387 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
App 387 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
[

但是当我 docker exec -it [container] /bin/bash 然后 运行 rails c -e production,它连接成功,我可以查询数据库。

你遇到过这个问题吗?

您的应用程序正在尝试加载 ActiveRecord。如果您只使用 MongoDB,请按照 here.

的说明移除 ActiveRecord 相关配置

确保 individual Rails components are loaded 而不是全部 Rails 其中包括 ActiveRecord。