1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models/content.rb
Matthew Draper 87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30

40 lines
814 B
Ruby

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