aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-04 11:54:59 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-04 11:54:59 -0300
commit40f9407b872add660db45e59316a5a195f16d563 (patch)
treefddcabd86b2894279c36fa4e5a1797a87bb1cba6 /activerecord/lib/active_record/reflection.rb
parent2198a9fc0d2e27f828d452129ce47ad90e16fab7 (diff)
parent0b6358beb417f69c47edd93d099906cc818855ee (diff)
downloadrails-40f9407b872add660db45e59316a5a195f16d563.tar.gz
rails-40f9407b872add660db45e59316a5a195f16d563.tar.bz2
rails-40f9407b872add660db45e59316a5a195f16d563.zip
Merge pull request #16801 from eileencodes/refactor-scope_chain-on-through-refelction-to-eliminate-branch-in-eval_scope
Always add lambda to scope chain to eliminate branch in eval_scope
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index c0deb76a33..6b5a592ee5 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -728,8 +728,11 @@ module ActiveRecord
through_scope_chain = through_reflection.scope_chain.map(&:dup)
if options[:source_type]
- through_scope_chain.first <<
- through_reflection.klass.where(foreign_type => options[:source_type])
+ type = foreign_type
+ source_type = options[:source_type]
+ through_scope_chain.first << lambda { |object|
+ where(type => source_type)
+ }
end
# Recursively fill out the rest of the array from the through reflection