I have User
model with CanCan authorisation.
So user have role
attribute from this array: => ['doctor', 'patient']
class Shift < ActiveRecord::Base
belongs_to :doctor, class_name: "User", foreign_key: :user_id
belongs_to :day
validates :shift, presence: true
validates :cardiologist, presence: true
end
How should I write validator to allow create Shifts
only for doctors
and not allow to create shift where user_id
attribute is not a patient
id?