I would like to validate the uniqueness of a record within a date range.
For example : I want a customer attached to a post office within a date
range arrives(date) and departs (date).
So this is ok:
customer1; postoffice1; Feb1(arrives);Mar1(departs)
customer1; postoffice1; Mar2(arrives);Apr1(departs)
This however is NOT ok:
customer1; postoffice1; Feb1(arrives);Mar1(departs)
customer1; postoffice1; Jan1(arrives);Feb10(departs) [xxx overlapping
dates xxx]
The validation clause for this would be?
? validates_uniqueness_of :customer_id, :scope =>
[:postoffice_id,:arrives,:departs], :message=>“This unit with this
arrival date for this PSO already exists.”
?
I dont think the above is right? How do I specify range within scope.