diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-22 16:12:24 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-22 16:12:24 +0900 |
commit | 109505843ff74585c2c30e3b187bced56ff3a08a (patch) | |
tree | 46fcd585cccd797240adeed02ed74e6de0ddfe59 /activerecord/test/models | |
parent | ebc28aa74af410c590534140cc4e4bd0b69a045a (diff) | |
parent | 3e71bc4b048bef2ae7723dde5082020fd984bbd6 (diff) | |
download | rails-109505843ff74585c2c30e3b187bced56ff3a08a.tar.gz rails-109505843ff74585c2c30e3b187bced56ff3a08a.tar.bz2 rails-109505843ff74585c2c30e3b187bced56ff3a08a.zip |
Merge pull request #31710 from eugeneius/indestructible_through_record
Don't update counter cache when through record was not destroyed
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/post.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/tagging.rb | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 780a2c17f5..b552f66787 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -106,6 +106,9 @@ class Post < ActiveRecord::Base end end + has_many :indestructible_taggings, as: :taggable, counter_cache: :indestructible_tags_count + has_many :indestructible_tags, through: :indestructible_taggings, source: :tag + 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 diff --git a/activerecord/test/models/tagging.rb b/activerecord/test/models/tagging.rb index 861fde633f..6d4230f6f4 100644 --- a/activerecord/test/models/tagging.rb +++ b/activerecord/test/models/tagging.rb @@ -14,3 +14,7 @@ class Tagging < ActiveRecord::Base belongs_to :taggable, polymorphic: true, counter_cache: :tags_count has_many :things, through: :taggable end + +class IndestructibleTagging < Tagging + before_destroy { throw :abort } +end |