@ -2,6 +2,8 @@
|
||||
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
|
||||
|
5
app/models/reviewer_to_quiz.rb
Normal file
5
app/models/reviewer_to_quiz.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
class ReviewerToQuiz < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :quiz
|
||||
end
|
@ -1,7 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
class User < ApplicationRecord
|
||||
has_secure_password
|
||||
has_many :candidates, foreign_key: "recruiter_id"
|
||||
has_many :candidates, foreign_key: :recruiter_id
|
||||
has_many :reviewer_to_quizzes
|
||||
has_many :quizzes, through: :reviewer_to_quizzes
|
||||
|
||||
validates :email, presence: true, uniqueness: true
|
||||
validates :name, presence: true
|
||||
|
Reference in New Issue
Block a user