Reputation: 127
leave_policy is table having columns :id ,:group_detail_id , employee_type_id,
I want to combination of :group_detail_id and employee_type_id should not be duplicate.
validates_uniqueness_of :employee_type_id ,:scope => :group_detail_id
this line is not working...I don't know why?????
Upvotes: 3
Views: 1249
Reputation: 2264
Try:
validate :unique_combination
def unique_combination
self.class.exists?(
:employee_type_id => employee_type_id,
:group_detail_id => group_detail_id
)
end
Upvotes: 2