diff options
author | Michael de Silva <michael@mwdesilva.com> | 2012-03-11 06:30:06 +0300 |
---|---|---|
committer | Michael de Silva <michael@mwdesilva.com> | 2012-03-11 06:30:06 +0300 |
commit | ce8df43a36510590f028c810fa36fe277bc68b01 (patch) | |
tree | c2aec66a928cfc77c671dd4bd573a4c566e4c3e1 | |
parent | 52bbff4e898ab00265580b34a06241d7d2c1571f (diff) | |
download | rails-ce8df43a36510590f028c810fa36fe277bc68b01.tar.gz rails-ce8df43a36510590f028c810fa36fe277bc68b01.tar.bz2 rails-ce8df43a36510590f028c810fa36fe277bc68b01.zip |
added clarification stating the counter_cache attribute needs to be created on the associate class via a migration
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b1a5110e2d..b901f06ca4 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1382,7 +1382,9 @@ module ActiveRecord # and +decrement_counter+. The counter cache is incremented when an object of this # class is created and decremented when it's destroyed. This requires that a column # named <tt>#{table_name}_count</tt> (such as +comments_count+ for a belonging Comment class) - # is used on the associate class (such as a Post class). You can also specify a custom counter + # is used on the associate class (such as a Post class) - that is the migration for + # <tt>#{table_name}_count</tt> is created on the associate class (such that Post.comments_count will + # return the count cached, see note below). You can also specify a custom counter # cache column by providing a column name instead of a +true+/+false+ value to this # option (e.g., <tt>:counter_cache => :my_custom_counter</tt>.) # Note: Specifying a counter cache will add it to that model's list of readonly attributes |