2024-06-05 18:45:45 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CharacterSheetSection < ApplicationRecord
|
|
|
|
belongs_to :character
|
2024-06-07 14:38:10 +00:00
|
|
|
belongs_to :parent_section, optional: true,
|
|
|
|
class_name: "CharacterSheetSection"
|
|
|
|
has_many :character_sheet_subsections, class_name: "CharacterSheetSection",
|
|
|
|
foreign_key: :parent_section_id,
|
|
|
|
dependent: :destroy
|
2024-06-12 15:17:27 +00:00
|
|
|
has_many :counters, dependent: :destroy
|
2024-06-07 14:38:10 +00:00
|
|
|
has_many :stats, dependent: :destroy
|
2024-06-05 18:45:45 +00:00
|
|
|
|
|
|
|
validates :name, presence: true,
|
|
|
|
length: { maximum: 255 }
|
|
|
|
|
|
|
|
scope :top_level, -> { where.missing(:parent_section) }
|
|
|
|
end
|