# Has-many-through relationship - deleting DB rows

**URL:** <https://www.ruby-forum.com/t/has-many-through-relationship-deleting-db-rows/91599>\
**Category:** Rails\
**Created:** [April 10, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/has-many-through-relationship-deleting-db-rows/91599 "2007-04-10T19:46:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [April 10, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/has-many-through-relationship-deleting-db-rows/91599/1 "2007-04-10T19:46:46Z")

</div>

I have group memberships modeled in a HMT relationship. My problem is,  
when  
a member is removed from a group, the relationship is not deleted, but  
the  
userid is merely set to 0.

[http://pastie.caboo.se/52837](http://pastie.caboo.se/52837)

Which makes me realize that I haven’t declared :dependent =\> :destroy in  
any  
of my relationships:

[http://pastie.caboo.se/52842](http://pastie.caboo.se/52842)

Is this possible with HTM? Sure, I could have the relationship destroyed  
if  
either of the two objects are destroyed. But what I also need is for the  
relationship to be destroyed if either of the object leave it. There  
must be  
a common solution for this?

Thanks!

–  
John Joseph B.  
[http://lyceum.ibiblio.org](http://lyceum.ibiblio.org)  
[http://blog.johnjosephbachir.org](http://blog.johnjosephbachir.org)  
aim/yim/msn/jabber.org/gtalk: johnjosephbachir  
713-494-2704  
[http://jjb.cc](http://jjb.cc)
