diff options
author | eileencodes <eileencodes@gmail.com> | 2014-11-06 19:05:12 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2015-01-02 17:15:30 -0500 |
commit | 092171da306609127dc50e7f45edadf4b27bc65d (patch) | |
tree | b2e50e896b4d60a0df57b52373d48dec270ed4b0 | |
parent | 076682692cd363765e6e5235c691474a071a01de (diff) | |
download | rails-092171da306609127dc50e7f45edadf4b27bc65d.tar.gz rails-092171da306609127dc50e7f45edadf4b27bc65d.tar.bz2 rails-092171da306609127dc50e7f45edadf4b27bc65d.zip |
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.
-rw-r--r-- | activerecord/lib/active_record/associations/association_scope.rb | 11 |
1 files changed, 3 insertions, 8 deletions
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 |