skill-assessment-app/app/models/quiz.rb

18 lines
440 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
2016-07-26 17:00:00 -05:00
class Quiz < ApplicationRecord
2016-07-28 20:54:08 -05:00
has_many :questions, -> { order(:sort) }
2016-07-27 11:17:50 -05:00
has_many :candidates
has_many :reviewer_to_quizzes
has_many :reviewers, through: :reviewer_to_quizzes, source: :user
2016-08-18 15:35:17 -05:00
2016-08-25 19:10:58 -05:00
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
2016-07-26 17:00:00 -05:00
end