From c1bc61cba0be6e5e830dae2f1497237f5ce3eb0d Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Sun, 14 Oct 2007 05:32:57 +0000 Subject: Add notes to documentation regarding attr_readonly behavior with counter caches and polymorphic associations. Closes #9835 [saimonmoore, rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7873 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index ab4e02f86c..3bf660f7b2 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -775,8 +775,11 @@ module ActiveRecord # destroyed. This requires that a column named #{table_name}_count (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 cache column by providing # a column name instead of a +true+/+false+ value to this option (e.g., :counter_cache => :my_custom_counter.) + # Note: Specifying a counter_cache will add it to that model's list of readonly attributes using #attr_readonly. # * :include - specify second-order associations that should be eager loaded when this object is loaded. # * :polymorphic - specify this association is a polymorphic association by passing +true+. + # Note: If you've enabled the counter cache, then you may want to add the counter cache attribute + # to the attr_readonly list in the associated classes (e.g. class Post; attr_readonly :comments_count; end). # # Option examples: # belongs_to :firm, :foreign_key => "client_of" -- cgit v1.2.3