I’m wondering how I would go about getting a :dependent behavior on a
habtm relation… It seems logical enough not to have :dependent on
habtms, because habtm usually has to do with two different models that
are “valid in themselves, independently of each other”, or how to put
But, in this particular case, the models are actually dependent. What
I have are users, businesses, and addresses. A user can have a number
of addresses, and they will belong to this user only. Likewise, a
business can have a number of addresses, which again belong only to
So, I really do need the M2M-table but it’s not really a “has and
belongs to many” relationship, it’s actually more like a “user has
many addresses, but so do business, and thus I can’t have a foreign
key to user in an address”.
Finally, when I delete a user, I’d like for the addresses to be
deleted as well. But I don’t have a :dependent option…
What would you do?
Thanks in advance,