course_participation.rb 338 B

12345678910111213
  1. class CourseParticipation < ApplicationRecord
  2. belongs_to :course
  3. belongs_to :user
  4. validates :course_id, presence: true
  5. validates :user_id, presence: true
  6. enum role: [:student, :teacher]
  7. scope :teachers, -> { where(role: :teacher) }
  8. scope :students, -> { where(role: :student) }
  9. default_scope { order(role: :desc) }
  10. end