diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-13 17:51:07 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-08-13 17:51:07 -0300 |
commit | 0168ce10a31ff2a00e2bce1c81ffbb25f0500281 (patch) | |
tree | c04467e96924fe3c69db9301c60a3f36c0d36ef8 /activerecord/test/models | |
parent | 33dc653466c0058740611259956712a9027801b3 (diff) | |
parent | 543523045112c5f5920c486e6fcf2d7e1ffedf5a (diff) | |
download | rails-0168ce10a31ff2a00e2bce1c81ffbb25f0500281.tar.gz rails-0168ce10a31ff2a00e2bce1c81ffbb25f0500281.tar.bz2 rails-0168ce10a31ff2a00e2bce1c81ffbb25f0500281.zip |
Merge pull request #19683 from tristang/require-option-for-counter-cache
Require explicit counter_cache option for has_many
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/categorization.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/treasure.rb | 1 |
3 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/test/models/categorization.rb b/activerecord/test/models/categorization.rb index 6588531de6..4cd67c970a 100644 --- a/activerecord/test/models/categorization.rb +++ b/activerecord/test/models/categorization.rb @@ -1,6 +1,6 @@ class Categorization < ActiveRecord::Base belongs_to :post - belongs_to :category + belongs_to :category, counter_cache: true belongs_to :named_category, :class_name => 'Category', :foreign_key => :named_category_name, :primary_key => :name belongs_to :author diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 10f13b67da..81a18188d4 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -98,11 +98,11 @@ class Post < ActiveRecord::Base end 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 :taggings_with_delete_all, :class_name => 'Tagging', :as => :taggable, :dependent => :delete_all, counter_cache: :taggings_with_delete_all_count + has_many :taggings_with_destroy, :class_name => 'Tagging', :as => :taggable, :dependent => :destroy, counter_cache: :taggings_with_destroy_count - has_many :tags_with_destroy, :through => :taggings, :source => :tag, :dependent => :destroy - has_many :tags_with_nullify, :through => :taggings, :source => :tag, :dependent => :nullify + has_many :tags_with_destroy, :through => :taggings, :source => :tag, :dependent => :destroy, counter_cache: :tags_with_destroy_count + has_many :tags_with_nullify, :through => :taggings, :source => :tag, :dependent => :nullify, counter_cache: :tags_with_nullify_count has_many :misc_tags, -> { where :tags => { :name => 'Misc' } }, :through => :taggings, :source => :tag has_many :funky_tags, :through => :taggings, :source => :tag diff --git a/activerecord/test/models/treasure.rb b/activerecord/test/models/treasure.rb index ffc65466d5..63ff0c23ec 100644 --- a/activerecord/test/models/treasure.rb +++ b/activerecord/test/models/treasure.rb @@ -1,6 +1,7 @@ class Treasure < ActiveRecord::Base has_and_belongs_to_many :parrots belongs_to :looter, :polymorphic => true + # No counter_cache option given belongs_to :ship has_many :price_estimates, :as => :estimate_of |