aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-06-01 15:57:29 +0930
committerGitHub <noreply@github.com>2017-06-01 15:57:29 +0930
commitf52fde15e1d3f0bd31c20e101e8f64930d671505 (patch)
tree5d3c87869376b18f4a179490662076cdd7539629 /activerecord/lib/active_record
parentd83558249c69577c3145c1db64870de98411a612 (diff)
parentc11109da934d71b1d0a139da36e52423844fa36e (diff)
downloadrails-f52fde15e1d3f0bd31c20e101e8f64930d671505.tar.gz
rails-f52fde15e1d3f0bd31c20e101e8f64930d671505.tar.bz2
rails-f52fde15e1d3f0bd31c20e101e8f64930d671505.zip
Merge pull request #29293 from kamipo/fix_sti_with_default_scope
Fix `default_scoped` with defined `default_scope` on STI model
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/scoping/default.rb6
1 files changed, 5 insertions, 1 deletions
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