candidate creation

This commit is contained in:
Mark Moser
2016-07-31 14:47:15 -05:00
parent 7758f8993c
commit abb3dee9f5
8 changed files with 92 additions and 8 deletions

View File

@ -4,11 +4,14 @@ class Candidate < ApplicationRecord
has_many :answers
belongs_to :recruiter, class_name: "User"
before_create :generate_test_hash
before_validation(:generate_test_hash, on: :create)
validates_presence_of :name
validates_presence_of :email
validates_presence_of :experience
validates_presence_of :recruiter_id
validates_presence_of :test_hash
validates_uniqueness_of :test_hash
validates :email, uniqueness: true, presence: true, email_format: true
validates :test_hash, uniqueness: true, presence: true
def submitted_answers
answers.where(submitted: true)