# :dependent =\> :destroy\_unconditionally?

**URL:** <https://www.ruby-forum.com/t/dependent-destroy-unconditionally/87889>\
**Category:** Rails\
**Created:** [March 6, 2007, 5:12pm UTC](https://www.ruby-forum.com/t/dependent-destroy-unconditionally/87889 "2007-03-06T17:12:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [March 6, 2007, 5:12pm UTC](https://www.ruby-forum.com/t/dependent-destroy-unconditionally/87889/1 "2007-03-06T17:12:39Z")

</div>

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 🙂
