Sha256: ce332748fdd53b06301288a7c6be4427e80691a065e823256f531732ccf10174

Contents?: true

Size: 814 Bytes

Versions: 8

Compression:

Stored size: 814 Bytes

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
ibm_db-5.2.0 test/models/content.rb
ibm_db-5.1.0 test/models/content.rb
ibm_db-5.0.5 test/models/content.rb
ibm_db-5.0.4 test/models/content.rb
ibm_db-5.0.3 test/models/content.rb
ibm_db-5.0.2 test/models/content.rb
ibm_db-4.0.0-x86-mingw32 test/models/content.rb
ibm_db-4.0.0 test/models/content.rb