Clear up dependency destruction chain
Buckets destroy their bubbles, which destroy their thread entries, which destroy their threadables, which is how comments end up destroyed, and then rollups end up deleting their events
This commit is contained in:
@@ -2,7 +2,7 @@ module Bubble::Commentable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_many :comments, dependent: :destroy
|
||||
has_many :comments
|
||||
|
||||
scope :ordered_by_comments, -> { left_joins(:comments).group(:id).order("COUNT(comments.id) DESC") }
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ module Bubble::Eventable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_many :events, dependent: :delete_all
|
||||
has_many :events
|
||||
|
||||
after_create -> { track_event :created }
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ module Threadable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_one :thread_entry, as: :threadable, dependent: :destroy
|
||||
has_one :thread_entry, as: :threadable
|
||||
|
||||
after_create { create_thread_entry! bubble: bubble }
|
||||
after_update { bubble.touch }
|
||||
|
||||
@@ -3,5 +3,5 @@ class Rollup < ApplicationRecord
|
||||
|
||||
belongs_to :bubble
|
||||
|
||||
has_many :events, -> { chronologically }
|
||||
has_many :events, -> { chronologically }, dependent: :delete_all
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class ThreadEntry < ApplicationRecord
|
||||
belongs_to :bubble
|
||||
|
||||
delegated_type :threadable, types: %w[ Comment Rollup ]
|
||||
delegated_type :threadable, types: %w[ Comment Rollup ], dependent: :destroy
|
||||
|
||||
scope :chronologically, -> { order created_at: :asc, id: :desc }
|
||||
end
|
||||
|
||||
Vendored
+12
@@ -24,5 +24,17 @@ logo_5:
|
||||
created_at: <%= 1.hour.ago %>
|
||||
|
||||
layout_1:
|
||||
bubble: layout
|
||||
threadable: layout_initial_activity (Rollup)
|
||||
|
||||
layout_2:
|
||||
bubble: layout
|
||||
threadable: layout_overflowing_david (Comment)
|
||||
|
||||
text_1:
|
||||
bubble: text
|
||||
threadable: text_initial_activity (Rollup)
|
||||
|
||||
shipping_1:
|
||||
bubble: shipping
|
||||
threadable: shipping_initial_activity (Rollup)
|
||||
|
||||
Reference in New Issue
Block a user