Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add notes to documentation regarding attr_readonly behavior with coun…

…ter caches and polymorphic associations. Closes #9835 [saimonmoore, rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7873 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c1bc61cba0be6e5e830dae2f1497237f5ce3eb0d 1 parent f56dd10
@technoweenie technoweenie authored
View
2  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]
View
3  activerecord/lib/active_record/associations.rb
@@ -775,8 +775,11 @@ def has_one(association_id, options = {})
# 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"
Please sign in to comment.
Something went wrong with that request. Please try again.