aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-12-05 15:17:34 +0000
committerMarcel Molina <marcel@vernix.org>2007-12-05 15:17:34 +0000
commit1b7a18dec8ed78ea989270fc3140260fc87c310e (patch)
treea50c5b384b186e0eec5ac6a9e9f5faa84d31d2ee /activerecord
parent6a45e01b3262a5d6b07535c872fdc74d3abad8c0 (diff)
downloadrails-1b7a18dec8ed78ea989270fc3140260fc87c310e.tar.gz
rails-1b7a18dec8ed78ea989270fc3140260fc87c310e.tar.bz2
rails-1b7a18dec8ed78ea989270fc3140260fc87c310e.zip
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
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb16
2 files changed, 12 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 06e19641c7..f4d2474178 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Document options and add examples for update. Closes #7985 [fearoffish]
+
* Document options and add examples for delete. Closes #7986 [fearoffish]
* Document options and add examples for destroy. Closes #7988 [fearoffish]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 19077920ff..1b76836de5 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -486,16 +486,20 @@ module ActiveRecord #:nodoc:
end
end
- # Finds the record from the passed +id+, instantly saves it with the passed +attributes+ (if the validation permits it),
- # and returns it. If the save fails under validations, the unsaved object is still returned.
+ # Updates an object (or multiple objects) and saves it to the database, if validations pass.
+ # The resulting object is returned whether the object was saved successfully to the database or not.
#
- # The arguments may also be given as arrays in which case the update method is called for each pair of +id+ and
- # +attributes+ and an array of objects is returned.
+ # ==== Options
+ #
+ # +id+ This should be the id or an array of ids to be updated
+ # +attributes+ This should be a Hash of attributes to be set on the object, or an array of Hashes.
+ #
+ # ==== Examples
#
- # Example of updating one record:
+ # # Updating one record:
# Person.update(15, {:user_name => 'Samuel', :group => 'expert'})
#
- # Example of updating multiple records:
+ # # Updating multiple records:
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
# Person.update(people.keys, people.values)
def update(id, attributes)