diff options
author | Xavier Noria <fxn@hashref.com> | 2010-08-12 17:36:09 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-08-12 17:36:09 +0200 |
commit | 4134d7db34506887f5cb945bb4e51c53c5f67ec3 (patch) | |
tree | 161991a34115f2ecd41725ab65af0895b93489ed /activerecord/lib/active_record/named_scope.rb | |
parent | e4943e93c2571cba8630eec2e77000300947866b (diff) | |
parent | 8af2186d26c77f6fcb0787f50941ebe1a2905c5f (diff) | |
download | rails-4134d7db34506887f5cb945bb4e51c53c5f67ec3.tar.gz rails-4134d7db34506887f5cb945bb4e51c53c5f67ec3.tar.bz2 rails-4134d7db34506887f5cb945bb4e51c53c5f67ec3.zip |
Merge remote branch 'docrails/master'
Diffstat (limited to 'activerecord/lib/active_record/named_scope.rb')
-rw-r--r-- | activerecord/lib/active_record/named_scope.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 0e560418dc..bffc450f8e 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -88,6 +88,15 @@ module ActiveRecord # end # end # end + # + # Scopes can also be used while creating/building a record. + # + # class Article < ActiveRecord::Base + # scope :published, where(:published => true) + # end + # + # Article.published.new.published # => true + # Article.published.create.published # => true def scope(name, scope_options = {}, &block) name = name.to_sym valid_scope_name?(name) |