* create mentor relationship table and begin dashboard * add missing files from previous commit * add mentorship relationship status * remove uniqueness validation * add multiple notes * ban from mentorship deactives all relationships * add untracked files * fix logic issue and add specs * add model specs * add request specs * add request specs and fix linting * fix internal users spec * remove phantom columns * remove bizzaro character * move all attr_accessor to one line
14 lines
448 B
Ruby
14 lines
448 B
Ruby
class MentorRelationship < ApplicationRecord
|
|
belongs_to :mentor, class_name: "User"
|
|
belongs_to :mentee, class_name: "User"
|
|
validates :mentor, presence: true
|
|
validates :mentee, presence: true
|
|
validate :check_for_same_user
|
|
validates_uniqueness_of :mentor_id, scope: :mentee_id
|
|
|
|
def check_for_same_user
|
|
if mentor_id == mentee_id
|
|
errors.add(:mentor_relationship, "Mentor and Mentee cannot be the same person")
|
|
end
|
|
end
|
|
end
|