Skip to content
This repository
Browse code

Document automatically generated predicate methods for attributes. Cl…

…oses #10373 [chuyeow]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8280 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit e4d845ef54ff348afc8516c9168654ae6cd327c7 1 parent 519f2c9
authored December 05, 2007
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Document automatically generated predicate methods for attributes. Closes #10373 [chuyeow]
  4
+
3 5
 * Added ActiveRecord::Base#becomes to turn a record into one of another class (mostly relevant for STIs) [DHH]. Example:
4 6
 
5 7
     render :partial => @client.becomes(Company) # renders companies/company instead of clients/client
14  activerecord/lib/active_record/base.rb
@@ -155,6 +155,20 @@ def initialize(errors)
155 155
   # You can alternatively use self[:attribute]=(value) and self[:attribute] instead of write_attribute(:attribute, value) and
156 156
   # read_attribute(:attribute) as a shorter form.
157 157
   #
  158
+  # == Attribute query methods
  159
+  #
  160
+  # In addition to the basic accessors, query methods are also automatically available on the Active Record object.
  161
+  # Query methods allow you to test whether an attribute value is present.
  162
+  # 
  163
+  # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
  164
+  # to determine whether the user has a name:
  165
+  #
  166
+  #   user = User.new(:name => "David")
  167
+  #   user.name? # => true
  168
+  #
  169
+  #   anonymous = User.new(:name => "")
  170
+  #   anonymous.name? # => false
  171
+  #
158 172
   # == Accessing attributes before they have been typecasted
159 173
   #
160 174
   # Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first.

0 notes on commit e4d845e

Please sign in to comment.
Something went wrong with that request. Please try again.