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

Ticket #10373: document_ar_b_query_methods.diff

File document_ar_b_query_methods.diff, 1.2 kB (added by chuyeow, 1 year ago)
  • activerecord/lib/active_record/base.rb

    old new  
    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. 
    157157  # 
     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  # 
    158172  # == Accessing attributes before they have been typecasted 
    159173  # 
    160174  # Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first.