Pretty complicated question, but I’ll try my best.
I’m building an app in which the user can enter a Show. A Show has_many
items, and each Item has and belongs to many People. So, a person can
appear in many items (think interviews for instance) in many shows. Easy
so far, here comes my headache.
In the item form, I’d like to add people, if those people aren’t in
another item a couple of days around that item. So say person A is in
item X tomorrow, and a user tries to add item Y with person A also for
tomorrow, I’d like to show a warning for that.
I’m using Railscasts’ complex form trick for this all
(http://railscasts.com/episodes/75), and added an auto complete handler
to find a Person based on the name entered in the field.
Somehow I need to add a validation rule to check for recent shows
somewhere, but for that I need a Person and an Item, meaning I can’t put
it in the Person model and neither in the Item model.
I’m kinda stumped here, so if anyone has an idea, please help me out!