Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
Marcel Molina authored
Showing with 16 additions and 0 deletions.
  1. +2 −0  activerecord/CHANGELOG
  2. +14 −0 activerecord/lib/active_record/base.rb
View
2  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
View
14 activerecord/lib/active_record/base.rb
@@ -155,6 +155,20 @@ def initialize(errors)
# 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.
Please sign in to comment.
Something went wrong with that request. Please try again.