leave_policy is table having columns :id ,:group_detail_id , employee_type_id,
leave_policy是包含以下列的表:id,:group_detail_id, employee_type_id,
I want to combination of :group_detail_id and employee_type_id should not be duplicate.
我想合并:group_detail_id和employee_type_id不应该重复。
validates_uniqueness_of :employee_type_id ,:scope => :group_detail_id
validates_uniqueness_of:employee_type_id,:scope =>:group_detail_id。
this line is not working...I don't know why?????
这条线坏了……我不知道为什么? ? ? ? ?
1 个解决方案
#1
2
Try:
试一试:
validate :unique_combination
def unique_combination
self.class.exists?(
:employee_type_id => employee_type_id,
:group_detail_id => group_detail_id
)
end
#1
2
Try:
试一试:
validate :unique_combination
def unique_combination
self.class.exists?(
:employee_type_id => employee_type_id,
:group_detail_id => group_detail_id
)
end