Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8280

Show
Ignore:
Timestamp:
12/05/07 14:22:26 (5 months ago)
Author:
marcel
Message:

Document automatically generated predicate methods for attributes. Closes #10373 [chuyeow]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8259 r8280  
    11*SVN* 
     2 
     3* Document automatically generated predicate methods for attributes. Closes #10373 [chuyeow] 
    24 
    35* Added ActiveRecord::Base#becomes to turn a record into one of another class (mostly relevant for STIs) [DHH]. Example: 
  • trunk/activerecord/lib/active_record/base.rb

    r8260 r8280  
    155155  # You can alternatively use self[:attribute]=(value) and self[:attribute] instead of write_attribute(:attribute, value) and 
    156156  # read_attribute(:attribute) as a shorter form. 
     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 
    157171  # 
    158172  # == Accessing attributes before they have been typecasted