diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-04-08 20:56:33 +0100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-12 19:46:04 -0700 |
commit | 8572ae6671c6ec7c2524f327cee82215896e5648 (patch) | |
tree | b2ba0a04ef502725cee88886319fd8a3c841f404 /activerecord/lib/active_record/named_scope.rb | |
parent | 5740d4ec0c16d68b82f440e74fd8b74ae3fe48e6 (diff) | |
download | rails-8572ae6671c6ec7c2524f327cee82215896e5648.tar.gz rails-8572ae6671c6ec7c2524f327cee82215896e5648.tar.bz2 rails-8572ae6671c6ec7c2524f327cee82215896e5648.zip |
Evaluate default scopes at the last possible moment in order to avoid problems with default scopes getting included into other scopes and then being unable to remove the default part via unscoped.
Diffstat (limited to 'activerecord/lib/active_record/named_scope.rb')
-rw-r--r-- | activerecord/lib/active_record/named_scope.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index a398476dd6..68e3018e22 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -35,7 +35,13 @@ module ActiveRecord if options scoped.apply_finder_options(options) else - (current_scope || relation).clone + if current_scope + current_scope.clone + else + scope = relation.clone + scope.default_scoped = true + scope + end end end |