diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-29 18:20:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-07-29 18:21:04 -0700 |
commit | fbaae891ac5361a03aaea07bc95bc11b3c6e11fd (patch) | |
tree | a2288f69416669d90714aa11863569e6d4405098 /activerecord/lib/active_record | |
parent | 5304afcbb1122dbacc9b95e9a80c1a17ddc6920b (diff) | |
download | rails-fbaae891ac5361a03aaea07bc95bc11b3c6e11fd.tar.gz rails-fbaae891ac5361a03aaea07bc95bc11b3c6e11fd.tar.bz2 rails-fbaae891ac5361a03aaea07bc95bc11b3c6e11fd.zip |
only calculate the klass once
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/association_scope.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index bdfafa5066..62b9c94422 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -89,10 +89,11 @@ module ActiveRecord scope = scope.joins(join(foreign_table, constraint)) end + klass = i == 0 ? self.klass : reflection.klass + # Exclude the scope of the association itself, because that # was already merged in the #scope method. scope_chain[i].each do |scope_chain_item| - klass = i == 0 ? self.klass : reflection.klass item = eval_scope(klass, scope_chain_item) if scope_chain_item == self.reflection.scope |