class EcCourseAchievementMethod < ApplicationRecord
  belongs_to :ec_course
  belongs_to :ec_course_target
  belongs_to :ec_course_evaluation

  has_many :ec_achievement_evaluation_relates, dependent: :delete_all
  has_many :ec_course_evaluation_subitems, through: :ec_achievement_evaluation_relates

  validates :percentage, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 }

  accepts_nested_attributes_for :ec_achievement_evaluation_relates, allow_destroy: true
end
