# Multiple dependencies on Deletions

**URL:** <https://www.ruby-forum.com/t/multiple-dependencies-on-deletions/183093>\
**Category:** Rails\
**Created:** [February 8, 2010, 12:10am UTC](https://www.ruby-forum.com/t/multiple-dependencies-on-deletions/183093 "2010-02-08T00:10:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff\_aigner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@jeff\_aigner](https://www.ruby-forum.com/u/jeff_aigner)\
**Post date:** [February 8, 2010, 12:10am UTC](https://www.ruby-forum.com/t/multiple-dependencies-on-deletions/183093/1 "2010-02-08T00:10:11Z")

</div>

I’m having an interesting issue in terms of dependencies.

I have a truck record, which has\_one employee. Then I have a master  
record, which has\_many truck records. The problem is this:

If there exists a master record, with a truck record, with an  
employee, and the employee is then deleted, the truck record will be  
deleted. However, the deletion doesn’t cascade to the master record,  
so it becomes invalid. If the master record is then selected to be  
deleted, an error is returned saying that the truck record could not  
be found for deletion.

Currently I have them set up with the :dependent =\> :destroy

---

<div class="post-metadata">

**Author:** ![jeff\_aigner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/13edae/32.png) [@jeff\_aigner](https://www.ruby-forum.com/u/jeff_aigner)\
**Post date:** [February 8, 2010, 11:41am UTC](https://www.ruby-forum.com/t/multiple-dependencies-on-deletions/183093/2 "2010-02-08T11:41:15Z")

</div>

> the deletion doesn’t cascade to the master record  
> That makes sense, because it would mean that if one truck record is  
> deleted, then the rest of that masters truck records would also be  
> deleted as well.  
> Are you trying do delete the master record if it only has one truck  
> record?  
> If that’s the case then I belive you to handle it manually.
