app/models/employee_lunch.rb
# Enforce no two employees can be saved if from the same department (the logic to find matches can be circumveneted and result in matching same dept)
Enforce no two employees can be saved if from the same department (the logic to find matches can be circumveneted and result in matching same dept)
Enforce no two employees can be saved if from the same department ( the logic to find matches can be circumveneted and result in matching same dept )
def different_department
    unless lunch.blank?
      if lunch.employees.where(department: employee.department).count > 1
        errors.add(:employee, 'is not valid, they need to be from different depeartments')
      end
    end
  end
def different_department unless lunch . blank? if lunch . employees . where ( department : employee . department ) . count > 1 errors . add ( :employee , 'is not valid, they need to be from different depeartments' ) end end end
Enforce no two employees can be saved if from the same department (the logic to find matches can be circumveneted and result in matching same dept)
Enforce no two employees can be saved if from the same department ( the logic to find matches can be circumveneted and result in matching same dept )