I''ve been looking at this ticket: http://rails.lighthouseapp.com/projects/8994/tickets/643-named_scope-with-eager-loading-affects-activerecord-objects In a nutshell it''s about scoping. If you run Person.some_scope.find :all, :include => :friends Then the find on Person happens inside some_scope, which is fine, but if :friends has class_name Person (i.e. we have a self referential association) then the query we make to load the friends will also be scoped by some_scope, which is (I believe undesirable behaviour). I believe that changing association_preload.rb to wrap its finds in with_exclusive_scope solves the problem. That''s what my patch does and it fixes the failing test cases I wrote first. Can anyone think of a case where this would be throwing away scoping we didn''t want to throw away? That wouldn''t happen in the case above, since were we not eager loading then we;d do people = Person.some_scope.find :all people.first.friends... There''s no scoping on the fetch of friends, so my patch brings the eager loaded behaviour in line with the normal version. But what if one was to do Person.with_scope(...) do Person.find :all, :include => :friends end Is preloading throwing away the scope when it does its thing going to cause trouble here? Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---