diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-08-20 13:38:06 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-08-20 13:38:06 -0300 |
commit | 79bcab79d97239593c8f9500c70226abada341c6 (patch) | |
tree | 3c1aec608cd521e19e183ccf5147d19dda54b3ab /activerecord/lib/active_record/associations/through_association.rb | |
parent | b66bb42dc172716d29fb33c97799f1786af3ce9f (diff) | |
parent | 431f8e01196044877c2acea4271410b1033ec915 (diff) | |
download | rails-79bcab79d97239593c8f9500c70226abada341c6.tar.gz rails-79bcab79d97239593c8f9500c70226abada341c6.tar.bz2 rails-79bcab79d97239593c8f9500c70226abada341c6.zip |
Merge pull request #16172 from Agis-/hmt_scope_arity
has_many :through with dynamic condition merging
Diffstat (limited to 'activerecord/lib/active_record/associations/through_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 611d471e62..e47e81aa0f 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -15,7 +15,11 @@ module ActiveRecord scope = super reflection.chain.drop(1).each do |reflection| relation = reflection.klass.all - relation.merge!(reflection.scope) if reflection.scope + + reflection_scope = reflection.scope + if reflection_scope && reflection_scope.arity.zero? + relation.merge!(reflection_scope) + end scope.merge!( relation.except(:select, :create_with, :includes, :preload, :joins, :eager_load) |