aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-07-18 10:22:05 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-07-19 00:50:40 +0900
commitd13f54d50a166d49c683f79d49341185788faed8 (patch)
tree14468a7ece9ce1bfcc4aa06c027a50f722146170 /activerecord/lib/active_record/reflection.rb
parent58c567adaeba1208522640e7890db9e07cbb768a (diff)
downloadrails-d13f54d50a166d49c683f79d49341185788faed8.tar.gz
rails-d13f54d50a166d49c683f79d49341185788faed8.tar.bz2
rails-d13f54d50a166d49c683f79d49341185788faed8.zip
Fix unscoping `default_scope` in STI associations
Since 5c71000, it has lost to be able to unscope `default_scope` in STI associations. This change will use `.empty_scope?` instead of `.values.empty?` to regard as an empty scope if only have `type_condition`.
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 4f53280b5c..1026e20f79 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -219,8 +219,10 @@ module ActiveRecord
end
def klass_join_scope(table, predicate_builder) # :nodoc:
- if klass.current_scope && klass.current_scope.values.empty?
- klass.unscoped
+ current_scope = klass.current_scope
+
+ if current_scope && current_scope.empty_scope?
+ build_scope(table, predicate_builder)
else
klass.default_scoped(build_scope(table, predicate_builder))
end