:dependent => :destroy_unconditionally?

Hey…

I have these business_accounts that have a bunch of members through a
business_account_membership model. A membership can be a privileged,
“managing” one, and a business account should always have one such
privileged member, so I have a before_destroy filter on the
business_account_membership model to prevent the deletion of the last
managing member of a business account.

However, when deleting a business account, this constraint should no
longer be respected - if the business account dies, then the rule dies
with it. Only thing is, Rails tries to destroy all those managing
members before destroying the business account itself, because they’re
related like this:
has_many :members, { :class_name =>
‘BusinessAccountMembership’, :dependent => :destroy }

I would like to define in this relationship, or somewhere else, that
the dependent members should be destroyed without validating against
my before_destroy
filter :prevent_deletion_of_exclusive_business_account_manager.

Any ideas as to how I would go about doing that?

Thanks in advance,
Daniel :slight_smile: