module Sis module Core class ExamResult < ApplicationRecord PASS = 'Pass'.freeze FAIL = 'Fail'.freeze belongs_to :exam belongs_to :application validates :points, presence: true validates_uniqueness_of :application_id, scope: %i[exam_id] before_validation :set_status def set_status self.status = if exam && exam.pass_point >= points PASS else FAIL end end end end end