diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-27 21:00:06 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-27 21:00:06 -0700 |
commit | c81e4e6a2657f3f67b99a2f88e2909c36c9f3863 (patch) | |
tree | 7a1ed3017b80639d6266056577d3ca1d6fc77711 /activerecord/lib/active_record/scoping | |
parent | dd3ea17191e316aeebddaa7b176f6cfeee7a6365 (diff) | |
parent | 70a5e5638bfd3b2543bb9d4805cbefec84b6b1ce (diff) | |
download | rails-c81e4e6a2657f3f67b99a2f88e2909c36c9f3863.tar.gz rails-c81e4e6a2657f3f67b99a2f88e2909c36c9f3863.tar.bz2 rails-c81e4e6a2657f3f67b99a2f88e2909c36c9f3863.zip |
Merge pull request #14154 from al2o3cr/issue12770
Pass a base relation to build_default_scope when joining
Diffstat (limited to 'activerecord/lib/active_record/scoping')
-rw-r--r-- | activerecord/lib/active_record/scoping/default.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb index 73ab3b39aa..18190cb535 100644 --- a/activerecord/lib/active_record/scoping/default.rb +++ b/activerecord/lib/active_record/scoping/default.rb @@ -94,14 +94,14 @@ module ActiveRecord self.default_scopes += [scope] end - def build_default_scope # :nodoc: + def build_default_scope(base_rel = relation) # :nodoc: if !Base.is_a?(method(:default_scope).owner) # The user has defined their own default scope method, so call that evaluate_default_scope { default_scope } elsif default_scopes.any? evaluate_default_scope do - default_scopes.inject(relation) do |default_scope, scope| - default_scope.merge(unscoped { scope.call }) + default_scopes.inject(base_rel) do |default_scope, scope| + default_scope.merge(base_rel.scoping { scope.call }) end end end |