Sha256: 0fb328108db707f22775376c0f28c72b6cd78c9a3351aaf953fcbc9b18d82e54
Contents?: true
Size: 845 Bytes
Versions: 7
Compression:
Stored size: 845 Bytes
Contents
# frozen_string_literal: true class Content < ActiveRecord::Base self.table_name = "content" has_one :content_position, dependent: :destroy def self.destroyed_ids @destroyed_ids ||= [] end before_destroy do |object| Content.destroyed_ids << object.id end end class ContentWhichRequiresTwoDestroyCalls < ActiveRecord::Base self.table_name = "content" has_one :content_position, foreign_key: "content_id", dependent: :destroy after_initialize do @destroy_count = 0 end before_destroy do @destroy_count += 1 if @destroy_count == 1 throw :abort end end end class ContentPosition < ActiveRecord::Base belongs_to :content, dependent: :destroy def self.destroyed_ids @destroyed_ids ||= [] end before_destroy do |object| ContentPosition.destroyed_ids << object.id end end
Version data entries
7 entries across 7 versions & 2 rubygems