class RaceStudent < ApplicationRecord
  include Base::RaceStudent

  audited associated_with: :student, only: :RaceID

  belongs_to :school,
    primary_key: :SchoolID,
    foreign_key: :SchoolID
  belongs_to :race,
    inverse_of: :race_students,
    primary_key: :SRID,
    foreign_key: :RaceID
  belongs_to :student,
    inverse_of: :race_students,
    primary_key: :StudentID,
    foreign_key: :StudentID

  before_validation do
    self.school = student.school
  end
end
