From 52f09eac5b3d297021ef726e04ec19f6011cb302 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 5 Feb 2011 13:13:49 +0000 Subject: Correctly update counter caches on deletion for has_many :through [#2824 state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business. --- activerecord/test/models/post.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 1c95d30d6b..fd8cd2244a 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -39,6 +39,7 @@ class Post < ActiveRecord::Base has_many :author_favorites, :through => :author has_many :author_categorizations, :through => :author, :source => :categorizations + has_many :author_addresses, :through => :author has_one :very_special_comment has_one :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post @@ -57,6 +58,10 @@ class Post < ActiveRecord::Base end has_many :taggings_with_delete_all, :class_name => 'Tagging', :as => :taggable, :dependent => :delete_all + has_many :taggings_with_destroy, :class_name => 'Tagging', :as => :taggable, :dependent => :destroy + + has_many :tags_with_destroy, :through => :taggings, :source => :tag, :dependent => :destroy + has_many :tags_with_nullify, :through => :taggings, :source => :tag, :dependent => :nullify has_many :misc_tags, :through => :taggings, :source => :tag, :conditions => "tags.name = 'Misc'" has_many :funky_tags, :through => :taggings, :source => :tag -- cgit v1.2.3