Add error on existing supplier name for current employee

This commit is contained in:
2015-02-24 18:18:55 +01:00
parent db72cd06aa
commit fd871639b9
3 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -51,6 +51,6 @@ class NewSupplier
def supplier_name_uniqueness
return unless current_employee.present? and supplier_name.present?
current_suppliers = current_employee.suppliers
errors.add :base, 'You already have a supplier with that name' if current_suppliers.map(&:name).include? supplier_name
errors.add :supplier_name, 'You already have a supplier with that name' if current_suppliers.map(&:name).include? supplier_name
end
end