indentlabs/notebook

View on GitHub
app/models/page_groupers/fathership.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Fathership < ApplicationRecord
  include HasContentLinking

  belongs_to :user, optional: true

  belongs_to :character
  belongs_to :father, class_name: 'Character', optional: true

  # after_create do
  #   this_object  = Character.find_by(id: self.character_id)
  #   other_object = Character.find_by(id: self.father_id)

  #   # If this character is marked as the father 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.father_id)

  #   other_object.children.delete(this_object) if other_object.present?
  # end
end