[英]`load_missing_constant': Circular dependency detected while autoloading constant ApplicationRecord (RuntimeError)
After Upgrading from Rails 4.2 to Rails 5.0, I received this error:从 Rails 4.2 升级到 Rails 5.0 后,我收到此错误:
`load_missing_constant': Circular dependency detected while autoloading constant ApplicationRecord (RuntimeError)
This is such a simple thing to miss so I thought I should mentioned it.这是一件很容易错过的事情,所以我想我应该提到它。
If you tried to "Auto Replace" all of your models from:如果您尝试从以下位置“自动替换”所有模型:
class Model < ActiveRecord::Base
to至
class Model < ApplicationRecord
chances are, you probably replaced your app/models/application_record.rb
file with the same, and it looks like this right now:很有可能,您可能将app/models/application_record.rb
文件替换为相同的文件,现在看起来像这样:
class ApplicationRecord < ApplicationRecord
fix it back to read:将其修复为:
class ApplicationRecord < ActiveRecord::Base
and you should be good to go!你应该好好去!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.