mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
25 lines
944 B
Ruby
25 lines
944 B
Ruby
class Mothership < ApplicationRecord
|
|
include HasContentLinking
|
|
|
|
belongs_to :user, optional: true
|
|
|
|
belongs_to :character
|
|
belongs_to :mother, class_name: 'Character', optional: true
|
|
|
|
# after_create do
|
|
# this_object = Character.find_by(id: self.character_id)
|
|
# other_object = Character.find_by(id: self.mother_id)
|
|
|
|
# # If this character is marked as the mother of another character, we should mark that character as a child of this character
|
|
# other_object.childrenships.create(character: other_object, child: this_object) unless other_object.children.include?(this_object)
|
|
# end
|
|
|
|
# after_destroy do
|
|
# # This is a two-way relation, so we should also delete the reverse association
|
|
# this_object = Character.find_by(id: self.character_id)
|
|
# other_object = Character.find_by(id: self.mother_id)
|
|
|
|
# other_object.children.delete(this_object) if other_object.present? && this_object.present?
|
|
# end
|
|
end
|