Skip to content
This repository
Browse code

Enhance documentation for decrement_counter. Closes #8093. [fearoffish]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6683 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5bd35705cae2e465b2fe2b2038bb409b63b78438 1 parent 194b4aa
authored May 06, 2007
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Enhance documentation for decrement_counter. [fearoffish]
  4
+
3 5
 * Provide brief introduction to what optimistic locking is. [fearoffish]
4 6
 
5 7
 * Add documentation for :encoding option to mysql adapter. [marclove]
14  activerecord/lib/active_record/base.rb
@@ -564,7 +564,19 @@ def increment_counter(counter_name, id)
564 564
         update_counters(id, counter_name => 1)
565 565
       end
566 566
 
567  
-      # Works like increment_counter, but decrements instead.
  567
+      # Decrement a number field by one, usually representing a count.
  568
+      #
  569
+      # This works the same as increment_counter but reduces the column value by 1 instead of increasing it.
  570
+      #
  571
+      # ==== Options
  572
+      #
  573
+      # +counter_name+  The name of the field that should be decremented
  574
+      # +id+            The id of the object that should be decremented
  575
+      #
  576
+      # ==== Examples
  577
+      #
  578
+      #   # Decrement the post_count column for the record with an id of 5
  579
+      #   DiscussionBoard.decrement_counter(:post_count, 5)
568 580
       def decrement_counter(counter_name, id)
569 581
         update_counters(id, counter_name => -1)
570 582
       end

0 notes on commit 5bd3570

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