I have a simple app with 3 models - Restaurant, Employee, and User. My Restaurant model has_many employees and I can hire other employees by creating them and giving a value to an attribute user_id of the employee. How to check for the presence of User with id=user_id before saving the new employee? Thank you!
EDIT======= The solution
validate :user_exists def user_exists if User.exists?(self.user_id) return true else self.errors.add(:user_id, "Unable to find this user.") return false end end