Skip to content
This repository
Browse code

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

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8293 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 1b7a18dec8ed78ea989270fc3140260fc87c310e 1 parent 6a45e01
authored December 05, 2007
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Document options and add examples for update. Closes #7985 [fearoffish]
  4
+
3 5
 * Document options and add examples for delete. Closes #7986 [fearoffish]
4 6
 
5 7
 * Document options and add examples for destroy. Closes #7988 [fearoffish]
16  activerecord/lib/active_record/base.rb
@@ -486,16 +486,20 @@ def create(attributes = nil)
486 486
         end
487 487
       end
488 488
 
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.
  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 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.
  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
494 498
       #
495  
-      # Example of updating one record:
  499
+      #   # Updating one record:
496 500
       #   Person.update(15, {:user_name => 'Samuel', :group => 'expert'})
497 501
       # 
498  
-      # Example of updating multiple records:
  502
+      #   # Updating multiple records:
499 503
       #   people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} } 	
500 504
       #   Person.update(people.keys, people.values)
501 505
       def update(id, attributes)

0 notes on commit 1b7a18d

Please sign in to comment.
Something went wrong with that request. Please try again.