aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb12
2 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 14ce50536e..54001561fb 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Document options for update_counters. Closes #8091 [fearoffish]
+
* Add documentation about the virtual attribute added by validates_confirmation_of and its behavior. Closes #8815 [JEG2, matt, kampers]
* Add documentation for freeze and readonly related methods. Closes #8878 [pelargir, jeremymcanally]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 616b164b13..dad0573d88 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -574,7 +574,19 @@ module ActiveRecord #:nodoc:
# with the given ID, altering the given hash of counters by the amount
# given by the corresponding value:
#
+ # ==== Options
+ #
+ # +id+ The id of the object you wish to update a counter on
+ # +counters+ An Array of Hashes containing the names of the fields
+ # to update as keys and the amount to update the field by as
+ # values
+ #
+ # ==== Examples
+ #
+ # # For the Post with id of 5, decrement the comment_count by 1, and
+ # # increment the action_count by 1
# Post.update_counters 5, :comment_count => -1, :action_count => 1
+ # # Executes the following SQL:
# # UPDATE posts
# # SET comment_count = comment_count - 1,
# # action_count = action_count + 1