validate employee id uniqueness by shop_code

This commit is contained in:
Thein Lin Kyaw
2020-07-11 11:50:20 +06:30
parent b033db0e55
commit 161a509aba

View File

@@ -8,7 +8,7 @@ class Employee < ApplicationRecord
validates_presence_of :name, :role
validates_presence_of :password, :on => [:create]
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
validates :emp_id, uniqueness: { scope: :shop_code }, numericality: true, length: {in: 1..4}, allow_blank: true
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
before_create :generate_app_id, :generate_app_token,