aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Chelimsky + Brian Tatnall <dchelimsky@gmail.com>2010-05-14 16:30:12 -0500
committerJosé Valim <jose.valim@gmail.com>2010-05-15 08:38:28 +0200
commit35a114a8941cb22d29a536f1215a23a8cf7c4756 (patch)
treeab4191bbaa7a87735d9e4fb7cd80ac63bd578c2f /activerecord/lib
parenta0621c1086165e4b3cff71b54f08a190851b6314 (diff)
downloadrails-35a114a8941cb22d29a536f1215a23a8cf7c4756.tar.gz
rails-35a114a8941cb22d29a536f1215a23a8cf7c4756.tar.bz2
rails-35a114a8941cb22d29a536f1215a23a8cf7c4756.zip
Modified default_scope to merge with any pre-existing default_scope
and added AR::Base::clear_default_scope - clear_default_scope provides users who rely on the old behaviour of each call to default_scope overwriting any previous default scopes an opportunity to maintain that behaviour. [#4583 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 650a91b385..e7319ce8b9 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1190,7 +1190,11 @@ module ActiveRecord #:nodoc:
# default_scope order('last_name, first_name')
# end
def default_scope(options = {})
- self.default_scoping << construct_finder_arel(options)
+ self.default_scoping << construct_finder_arel(options, default_scoping.pop)
+ end
+
+ def clear_default_scope
+ self.default_scoping.clear
end
def scoped_methods #:nodoc: