docbrown/app/models/mentor_relationship.rb
Jess Lee 4451e5eb38 Update User Dashboard With Mentorship Admin Features (#440)
* 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
2018-09-11 15:59:25 -04:00

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