title: Circular dependency detected while autoloading a constant
body: <p>I upgraded Rails from version 3.1.2 (which worked fine) to 4.0, and got stuck with the following error:</p>
  
  <pre><code>circular dependency detected while autoloading constant Foo
  </code></pre>
  
  <p>I created a class <code>ProductFactory</code>, where I instantiate different models. For example:</p>
  
  <pre><code>p = Foo.new(params)
  </code></pre>
  
  <p>The model <code>"Foo"</code> is not always an ActiveRecord. Could anyone help me with this issue?</p>