aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-01-30 16:36:17 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2017-01-30 16:36:17 -0800
commit4e5c2ccc1d97f0c18834f616fc219be6b1531bde (patch)
treec4f0d5c666342275e74f2a682456120ca0d16285 /activerecord
parentef7b9b867b3c113bbbc7639b5d760a8f962a683c (diff)
downloadrails-4e5c2ccc1d97f0c18834f616fc219be6b1531bde.tar.gz
rails-4e5c2ccc1d97f0c18834f616fc219be6b1531bde.tar.bz2
rails-4e5c2ccc1d97f0c18834f616fc219be6b1531bde.zip
Avoid lambda scopes when possible
Lambda scopes require a bunch more work. Ideally the `scope` list would be a homogeneous collection. In this case, the reflection knows how to construct the right reflection for this join, so lets just construct that relation rather than instance execing to figure it out later.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/reflection.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index d923050822..81ec4924b0 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -807,9 +807,7 @@ module ActiveRecord
end
def source_type_scope
- type = foreign_type
- source_type = options[:source_type]
- lambda { |object| where(type => source_type) }
+ through_reflection.klass.where(foreign_type => options[:source_type])
end
def has_scope?