I’m setting up a simple system for listing products and specials. I’m
looking for a way to validate that only one special can exist per
product per date range. For example, if a product is on sale from
2007-04-29 to 2007-05-10, you cannot create a special for that product
that starts on 2007-05-09.
What’s the best way to do this with Rails? I’m fairly new to RoR. I’ve
been looking for a way to do this with model validators, because I want
it to work as smoothly as the regular presence validators and all that.
Any help would be appreciated. I expect I’m going to have to write a
custom function to check this (the query is easy enough), but I’m not
sure where to put it or how to integrate it with your standard
Special.new call and all that.
The models in question: