diff options
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index b4d8b7b372..3d4d2aea2e 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Document automatically generated predicate methods for attributes. Closes #10373 [chuyeow] + * Added ActiveRecord::Base#becomes to turn a record into one of another class (mostly relevant for STIs) [DHH]. Example: render :partial => @client.becomes(Company) # renders companies/company instead of clients/client diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index b67a0d3e69..2d518a1ca1 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -155,6 +155,20 @@ module ActiveRecord #:nodoc: # You can alternatively use self[:attribute]=(value) and self[:attribute] instead of write_attribute(:attribute, value) and # read_attribute(:attribute) as a shorter form. # + # == Attribute query methods + # + # In addition to the basic accessors, query methods are also automatically available on the Active Record object. + # Query methods allow you to test whether an attribute value is present. + # + # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call + # to determine whether the user has a name: + # + # user = User.new(:name => "David") + # user.name? # => true + # + # anonymous = User.new(:name => "") + # anonymous.name? # => false + # # == Accessing attributes before they have been typecasted # # Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first. |