aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-03-03 11:29:05 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2017-03-03 11:29:48 -0800
commitc8e946683536e2555f98e0fa401b5a9721a9a6cb (patch)
treeb73388c52a74f1abc04f7194027d56d38b2baa5b /activerecord/lib/active_record/reflection.rb
parenta5651eb522bd656f21f2f2da57d6326a6bd28372 (diff)
downloadrails-c8e946683536e2555f98e0fa401b5a9721a9a6cb.tar.gz
rails-c8e946683536e2555f98e0fa401b5a9721a9a6cb.tar.bz2
rails-c8e946683536e2555f98e0fa401b5a9721a9a6cb.zip
ask reflection for klass join reflection
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 02aab25610..ba40db2de9 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -196,6 +196,21 @@ module ActiveRecord
end
end
+ def klass_join_scope(table, predicate_builder) # :nodoc:
+ if klass.current_scope
+ klass.current_scope.clone.tap { |scope|
+ scope.joins_values = []
+ }
+ else
+ relation = ActiveRecord::Relation.create(
+ klass,
+ table,
+ predicate_builder,
+ )
+ klass.send(:build_default_scope, relation)
+ end
+ end
+
def constraints
chain.map(&:scopes).flatten
end