# frozen_string_literal: true

module Answerly
  class Section < ApplicationRecord
    self.table_name = 'answerly_sections'

    belongs_to :survey, class_name: '::Answerly::Survey', inverse_of: :sections, foreign_key: :answerly_survey_id
    has_many :questions, class_name: '::Answerly::Question', dependent: :destroy, inverse_of: :section, foreign_key: :answerly_section_id
    has_many :comments, class_name: '::Answerly::Comment', dependent: :destroy, inverse_of: :section, foreign_key: :answerly_section_id
  
    accepts_nested_attributes_for :questions, allow_destroy: true
  end
end
