aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/counter_cache.rb
diff options
context:
space:
mode:
authorMatthew Robertson <matthewrobertson03@gmail.com>2012-12-02 19:35:35 -0800
committerMatthew Robertson <matthewrobertson03@gmail.com>2012-12-02 19:40:31 -0800
commit0a178000f5394c08e32346f42b05b17451ce4e42 (patch)
treede564c79adf963874ccdfb4957dab80d1e1c236f /activerecord/lib/active_record/counter_cache.rb
parent43405a75bd0ba7ec2a0add751ccd0a179e3129de (diff)
downloadrails-0a178000f5394c08e32346f42b05b17451ce4e42.tar.gz
rails-0a178000f5394c08e32346f42b05b17451ce4e42.tar.bz2
rails-0a178000f5394c08e32346f42b05b17451ce4e42.zip
grammar improvements for increment_counter and decrement_counter docs
Diffstat (limited to 'activerecord/lib/active_record/counter_cache.rb')
-rw-r--r--activerecord/lib/active_record/counter_cache.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 4c5326ead6..81f92db271 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -79,11 +79,12 @@ module ActiveRecord
where(primary_key => id).update_all updates.join(', ')
end
- # Increment a number field by one, usually representing a count.
+ # Increment a numeric field by one, via a direct SQL update.
#
- # This is used for caching aggregate values, so that they don't need to be computed every time.
- # For example, a DiscussionBoard may cache post_count and comment_count otherwise every time the board is
- # shown it would have to run an SQL query to find how many posts and comments there are.
+ # This method is used primarily for maintaining counter_cache columns used to
+ # store aggregate values. For example, a DiscussionBoard may cache posts_count
+ # and comments_count to avoid running an SQL query to calculate the number of
+ # posts and comments there are each time it is displayed.
#
# ==== Parameters
#
@@ -98,9 +99,10 @@ module ActiveRecord
update_counters(id, counter_name => 1)
end
- # Decrement a number field by one, usually representing a count.
+ # Decrement a numeric field by one, via a direct SQL update.
#
- # This works the same as increment_counter but reduces the column value by 1 instead of increasing it.
+ # This works the same as increment_counter but reduces the column value by
+ # 1 instead of increasing it.
#
# ==== Parameters
#