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

Changeset 8293

Show
Ignore:
Timestamp:
12/05/07 15:17:34 (1 year ago)
Author:
marcel
Message:

Document options and add examples for update. Closes #7985 [fearoffish]

Files:

Legend:

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

    r8292 r8293  
    11*SVN* 
     2 
     3* Document options and add examples for update. Closes #7985 [fearoffish] 
    24 
    35* Document options and add examples for delete. Closes #7986 [fearoffish] 
  • trunk/activerecord/lib/active_record/base.rb

    r8292 r8293  
    487487      end 
    488488 
    489       # Finds the record from the passed +id+, instantly saves it with the passed +attributes+ (if the validation permits it), 
    490       # and returns it. If the save fails under validations, the unsaved object is still returned. 
    491       # 
    492       # The arguments may also be given as arrays in which case the update method is called for each pair of +id+ and  
    493       # +attributes+ and an array of objects is returned. 
    494       # 
    495       # Example of updating one record: 
     489      # Updates an object (or multiple objects) and saves it to the database, if validations pass. 
     490      # The resulting object is returned whether the object was saved successfully to the database or not. 
     491      # 
     492      # ==== Options 
     493      # 
     494      # +id+          This should be the id or an array of ids to be updated 
     495      # +attributes+  This should be a Hash of attributes to be set on the object, or an array of Hashes. 
     496      # 
     497      # ==== Examples 
     498      # 
     499      #   # Updating one record: 
    496500      #   Person.update(15, {:user_name => 'Samuel', :group => 'expert'}) 
    497501      #  
    498       # Example of updating multiple records: 
     502      #   # Updating multiple records: 
    499503      #   people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }        
    500504      #   Person.update(people.keys, people.values)