自动加载常量时检测到循环依赖 [英] Circular dependency detected while autoloading a constant

查看:45
本文介绍了自动加载常量时检测到循环依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 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.

这篇关于自动加载常量时检测到循环依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆