aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-08-12 17:36:09 +0200
committerXavier Noria <fxn@hashref.com>2010-08-12 17:36:09 +0200
commit4134d7db34506887f5cb945bb4e51c53c5f67ec3 (patch)
tree161991a34115f2ecd41725ab65af0895b93489ed /activerecord/lib/active_record/base.rb
parente4943e93c2571cba8630eec2e77000300947866b (diff)
parent8af2186d26c77f6fcb0787f50941ebe1a2905c5f (diff)
downloadrails-4134d7db34506887f5cb945bb4e51c53c5f67ec3.tar.gz
rails-4134d7db34506887f5cb945bb4e51c53c5f67ec3.tar.bz2
rails-4134d7db34506887f5cb945bb4e51c53c5f67ec3.zip
Merge remote branch 'docrails/master'
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--activerecord/lib/active_record/base.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 8da4fbcba7..4b550eb446 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1147,6 +1147,16 @@ MSG
# class Person < ActiveRecord::Base
# default_scope order('last_name, first_name')
# end
+ #
+ # <tt>default_scope</tt> is also applied while creating/building a record. It is not
+ # applied while updating a record.
+ #
+ # class Article < ActiveRecord::Base
+ # default_scope where(:published => true)
+ # end
+ #
+ # Article.new.published # => true
+ # Article.create.published # => true
def default_scope(options = {})
self.default_scoping << construct_finder_arel(options, default_scoping.pop)
end