Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STI 或者有 model 继承的情况,初始化会出问题 #76

Open
bastengao opened this issue Apr 27, 2018 · 0 comments
Open

STI 或者有 model 继承的情况,初始化会出问题 #76

bastengao opened this issue Apr 27, 2018 · 0 comments

Comments

@bastengao
Copy link

执行 rails console 会报下面错,ps: 调用占是从上往下。初步定位是 descends_from_active_record? 方法 STI 检查时 load_schema, 这时数据库还没创建就报错了。

Gem 2.4.1
Rails 5.2.0
Ruby 2.5.0

24: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/second_level_cache-2.4.1/lib/second_level_cache/mixin.rb:17:in `second_level_cache'
 23: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/core.rb:286:in `relation'
 22: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:84:in `finder_needs_type_condition?'
 21: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:78:in `descends_from_active_record?'
 20: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:336:in `columns_hash'
 19: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:456:in `load_schema'
 18: from /Users/basten/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
 17: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:459:in `block in load_schema'
 16: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
 15: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/attributes.rb:234:in `load_schema!'
 14: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:466:in `load_schema!'
 13: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:90:in `connection'
 12: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
 11: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection'
 10: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection'
  9: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout'
  8: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection'
  7: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection'
  6: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection'
  5: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection'
  4: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `postgresql_connection'
  3: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `new'
  2: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:215:in `initialize'
  1: from /Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:683:in `connect'
/Users/basten/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:688:in `rescue in connect': FATAL:  database "xxx_dev" does not exist (ActiveRecord::NoDatabaseError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant