How do I validate two fields for uniqueness

前端 未结 2 924
忘了有多久
忘了有多久 2021-01-30 19:21

I need to validate the uniqueness of two fields in an object (row) before I add them. Employee_id and area_id are the two fields in my emp_area table. There can be multiple re

2条回答
  •  梦如初夏
    2021-01-30 20:23

    what about this solution Validate combined values

    validates :employee_id, uniqueness: { scope: :area_id }
    

提交回复
热议问题