0

我正在尝试从 ruby​​ 2.3.1 到 2.3.8 的小升级并面临一些问题。一切正常,直到我运行命令rake db:create并发现以下错误 -

rake aborted!
ActiveRecord::ConnectionNotEstablished: No connection pool for PublicActivity::ORM::ActiveRecord::Activity
/home/user/application/engines/admin/lib/admin/activity_extension.rb:10:in `<module:Admin>'
/home/user/application/engines/admin/lib/admin/activity_extension.rb:1:in `<top (required)>'
/home/user/application/engines/admin/lib/admin/engine.rb:8:in `<top (required)>'
/home/user/application/engines/admin/lib/admin.rb:1:in `require'
/home/user/application/engines/admin/lib/admin.rb:1:in `<top (required)>'
/home/user/application/config/application.rb:17:in `<top (required)>'
/home/user/application/Rakefile:4:in `<top (required)>'

我还追踪了错误并找到以下信息 -

rake aborted!
ActiveRecord::ConnectionNotEstablished: No connection pool for PublicActivity::ORM::ActiveRecord::Activity
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:570:in `retrieve_connection'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/connection_handling.rb:87:in `connection'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activerecord-4.2.11.3/lib/active_record/model_schema.rb:230:in `table_exists?'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record/activity.rb:47:in `<class:Activity>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record/activity.rb:22:in `<module:ActiveRecord>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record/activity.rb:19:in `<module:ORM>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record/activity.rb:18:in `<module:PublicActivity>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record/activity.rb:3:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record.rb:4:in `require_relative'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/orm/active_record.rb:4:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `block in require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity.rb:53:in `inherit_orm'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/models/activity.rb:4:in `<module:PublicActivity>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/public_activity-1.6.4/lib/public_activity/models/activity.rb:3:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `block in require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
/home/user/application/engines/admin/lib/admin/activity_extension.rb:10:in `<module:Admin>'
/home/user/application/engines/admin/lib/admin/activity_extension.rb:1:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `block in require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/activesupport-4.2.11.3/lib/active_support/dependencies.rb:274:in `require'
/home/user/application/engines/admin/lib/admin/engine.rb:8:in `<top (required)>'
/home/user/application/engines/admin/lib/admin.rb:1:in `require'
/home/user/application/engines/admin/lib/admin.rb:1:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `each'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `block in require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `each'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/bundler-1.17.3/lib/bundler.rb:114:in `require'
/home/user/application/config/application.rb:17:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/user/application/Rakefile:4:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:104:in `block in load_rakefile'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:103:in `load_rakefile'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:82:in `block in run'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/lib/rake/application.rb:80:in `run'
/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/home/user/.rbenv/versions/2.3.8/bin/rake:22:in `load'
/home/user/.rbenv/versions/2.3.8/bin/rake:22:in `<main>'

我无法找到错误的根本原因。请帮忙!

编辑 -

我试图在不同的系统上安装具有相同版本 ruby​​ 的应用程序,但它仍然显示相同的错误。新系统的配置有问题吗?

这是 database.yml 文件 -

default: &default
  adapter: postgresql
  encoding: unicode
  username: -----
  password: -----
  host: localhost
  port: 5432
  pool: 5

development:
  <<: *default
  database: -----
4

1 回答 1

0

adding as an answer, to include code blocks:

my database.yml:

default: &default
  adapter: postgresql
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: project-dev

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: project-test

production:
  <<: *default
  database: project

the adapter assumes localhost and port, and assumes username based on the current username (I access it without a password).

I don't know if the pool or timeout values are essential, but this configuration works for me.

于 2021-01-27T12:55:14.290 回答