diff options
-rw-r--r-- | activerecord/lib/active_record/associations/through_association.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 66b1616949..942abf7df1 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -14,11 +14,8 @@ module ActiveRecord def target_scope scope = super chain.drop(1).each do |reflection| - relation = if reflection.scope - reflection.klass.all.instance_eval(&reflection.scope) - else - reflection.klass.all - end + relation = reflection.klass.all + relation.instance_eval(&reflection.scope) if reflection.scope scope.merge!( relation.except(:select, :create_with, :includes, :preload, :joins, :eager_load) |