I'm wondering if there is any way to add validation to a "has_and_belongs_to_many collection attribute" (Room.people in my example) so that it limits the number of objects in the collection to some maximum?
I'm running into two problems here:
1. When I do the assignment to my collection (room.people = whatever), it IMMEDIATELY saves it in my join table (people_rooms) rather than waiting until I call room.save. (Shouldn't there be some way to explicitly defer the save?)
2. I thought maybe I could get around this by using habtm's :before_add option ... but it seems that any errors added there end up being ignored/lost. Plus, the only way to abort the save seems to be to raise an exception ... (which I don't really want to do).
Hopefully an example will help illustrate the problem. Here's the simplest test case I could come up with...