自动加载常量时检测到循环依赖
问题描述:
我将 Rails 从 3.1.2 版(运行良好)升级到 4.0,但遇到以下错误:
I upgraded Rails from version 3.1.2 (which worked fine) to 4.0, and got stuck with the following error:
circular dependency detected while autoloading constant Foo
我创建了一个类 ProductFactory
,我在其中实例化了不同的模型.例如:
I created a class ProductFactory
, where I instantiate different models. For example:
p = Foo.new(params)
模型 "Foo"
并不总是一个 ActiveRecord.有人能帮我解决这个问题吗?
The model "Foo"
is not always an ActiveRecord. Could anyone help me with this issue?
答
这种问题在你更换 Rails 版本时经常发生.您可能没有按正确的顺序更新宝石.
This kind of issues often happen when you change the version of Rails. You maybe didnt update the gems on the right order.