aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-10-14 05:32:57 +0000
committerRick Olson <technoweenie@gmail.com>2007-10-14 05:32:57 +0000
commitc1bc61cba0be6e5e830dae2f1497237f5ce3eb0d (patch)
treebe12fac759e2c2fd99bece54b6ea5d7a749e1597 /activerecord
parentf56dd107cdecb3cbffa04c320b4c30317331143d (diff)
downloadrails-c1bc61cba0be6e5e830dae2f1497237f5ce3eb0d.tar.gz
rails-c1bc61cba0be6e5e830dae2f1497237f5ce3eb0d.tar.bz2
rails-c1bc61cba0be6e5e830dae2f1497237f5ce3eb0d.zip
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
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/associations.rb3
2 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 27c4168c63..92852375ec 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add notes to documentation regarding attr_readonly behavior with counter caches and polymorphic associations. Closes #9835 [saimonmoore, rick]
+
* Observers can observe model names as symbols properly now. Closes #9869 [queso]
* find_and_(initialize|create)_by methods can now properly initialize protected attributes [Tobias Luetke]
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 <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 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 using #attr_readonly.
# * <tt>:include</tt> - specify second-order associations that should be eager loaded when this object is loaded.
# * <tt>:polymorphic</tt> - 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"