From c11109da934d71b1d0a139da36e52423844fa36e Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 31 May 2017 16:11:43 +0900 Subject: Fix `default_scoped` with defined `default_scope` on STI model This regression is caused by d1249c1. If STI model is defined `default_scope`, `base_rel` is not respected. I fixed to merge `base_rel` in that case. --- activerecord/lib/active_record/scoping/default.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb index ba5cc29ac1..70b2693b28 100644 --- a/activerecord/lib/active_record/scoping/default.rb +++ b/activerecord/lib/active_record/scoping/default.rb @@ -107,7 +107,11 @@ module ActiveRecord if default_scope_override # The user has defined their own default scope method, so call that - evaluate_default_scope { default_scope } + evaluate_default_scope do + if scope = default_scope + (base_rel ||= relation).merge(scope) + end + end elsif default_scopes.any? base_rel ||= relation evaluate_default_scope do -- cgit v1.2.3