skill-assessment-app/app/models/quiz.rb
2017-06-05 11:27:48 -05:00

18 lines
440 B
Ruby

# frozen_string_literal: true
class Quiz < ApplicationRecord
has_many :questions, -> { order(:sort) }
has_many :candidates
has_many :reviewer_to_quizzes
has_many :reviewers, through: :reviewer_to_quizzes, source: :user
validates :name, presence: true, uniqueness: true
validates :dept, presence: true
validates :unit, presence: true
class << self
def all_active
Quiz.joins(:questions).distinct
end
end
end