From 092171da306609127dc50e7f45edadf4b27bc65d Mon Sep 17 00:00:00 2001 From: eileencodes Date: Thu, 6 Nov 2014 19:05:12 -0500 Subject: Clean up assignments in `#add_constraints` `is_first_chain`, `items` and `klass` are no longer beneficial and can be called directly instead of via their assignments - because they are each only used once. --- .../lib/active_record/associations/association_scope.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 4907d1cf6c..b5a6954554 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -187,21 +187,16 @@ module ActiveRecord scope = next_chain_scope(scope, table, reflection, connection, assoc_klass, foreign_table, next_reflection) end - is_first_chain = i == 0 - klass = is_first_chain ? assoc_klass : reflection.klass - - items = reflection.constraints - # Exclude the scope of the association itself, because that # was already merged in the #scope method. - items.each do |scope_chain_item| - item = eval_scope(klass, scope_chain_item, owner) + reflection.constraints.each do |scope_chain_item| + item = eval_scope(reflection.klass, scope_chain_item, owner) if scope_chain_item == refl.scope scope.merge! item.except(:where, :includes, :bind) end - if is_first_chain + if i == 0 scope.includes! item.includes_values end -- cgit v1.2.3