aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-03-20 02:15:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-03-20 02:15:29 +0000
commit54213dadfde64e163d841056238b3c463aaa4212 (patch)
tree39fe86a2c5e79a1a67008fcbac34acf13caa4c15 /activerecord/lib/active_record/associations.rb
parente87d3e333588b8455c2b6d81219adb860c2f4baa (diff)
downloadrails-54213dadfde64e163d841056238b3c463aaa4212.tar.gz
rails-54213dadfde64e163d841056238b3c463aaa4212.tar.bz2
rails-54213dadfde64e163d841056238b3c463aaa4212.zip
Docfixes (closes #11356, #11172, #10523)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9064 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index d8332249fb..d7d5d9b312 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -809,6 +809,8 @@ 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>.)
+ # When creating a counter cache column, the database statement or migration must specify a default value of <tt>0</tt>, failing to do
+ # this results in a counter with NULL value, which will never increment.
# 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.
# Not allowed if the association is polymorphic.
@@ -824,6 +826,7 @@ module ActiveRecord
# :conditions => 'discounts > #{payments_count}'
# belongs_to :attachable, :polymorphic => true
# belongs_to :project, :readonly => true
+ # belongs_to :post, :counter_cache => true
def belongs_to(association_id, options = {})
reflection = create_belongs_to_reflection(association_id, options)