title: Rails: class' id / object_id changes during same request
body: <p>I have been having a problem when I try to compare two Rails models. They <em>should</em> evaluate as the same, but the way ActiveRecord implements == is causing it to fail. What's even stranger is the unit tests are passing.</p>
  
  <p>Suppose a User has many Posts, and Posts has many Comments. User also has_many comments.</p>
  
  <p>(and this is comparing two objects, which should be the same)</p>
  
  <pre><code>User.first.comments.first == Post.forst.comments.first
  </code></pre>
  
  <p>When I write out the object_ids to Rails.logger, they are not equal. After digging through the source code, I've found this condition makes it fail.</p>
  
  <p><a href="http://github.com/rails/rails/blob/30dcac292606da0e031d1e0dfbb6fc6109e5da60/activerecord/lib/active_record/base.rb#L1602" rel="nofollow">http://github.com/rails/rails/blob/30dcac292606da0e031d1e0dfbb6fc6109e5da60/activerecord/lib/active_record/base.rb#L1602</a></p>
  
  <p>I expect:</p>
  
  <pre><code>User.first.comments.class.object_id == Post.first.comments.class.object_id
  </code></pre>
  
  <p>But this is not the case.</p>
  
  <p>The model includes a module, which does the following inside self.included(base)</p>
  
  <pre><code>base.send :include, InstanceMethods
  base.send :extend,  ClassMethods
  </code></pre>
  
  <p>When I take the include out of the models, everything works fine. </p>
  
  <p>Is there something with the include/extend pattern that is causing the models to reload or not be cached correctly within the same request?</p>
  
  <p>Any ideas here would be great!!!</p>