# Has\_many\_through\_associations and delete with dependent

**URL:** <https://www.ruby-forum.com/t/has-many-through-associations-and-delete-with-dependent/128277>\
**Category:** Rails\
**Created:** [February 6, 2008, 11:14am UTC](https://www.ruby-forum.com/t/has-many-through-associations-and-delete-with-dependent/128277 "2008-02-06T11:14:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jahkub](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3da27b/32.png) [@jahkub](https://www.ruby-forum.com/u/jahkub)\
**Post date:** [February 6, 2008, 11:14am UTC](https://www.ruby-forum.com/t/has-many-through-associations-and-delete-with-dependent/128277/1 "2008-02-06T11:14:47Z")

</div>

Hi

let’s say I’ve the following associations

class User \< ActiveRecord::Base  
has\_many :user\_network\_privacies, :dependent =\> :destroy  
has\_many :networks, :through =\> :user\_network\_privacies  
end

class UserNetworkPrivacy \< ActiveRecord::Base  
belongs\_to :user  
belongs\_to :network

before\_destroy { puts “my before\_destroy callback” }  
end

I would expect the before\_destroy to be called when I do  
a\_user.networks.delete(a\_network) wich is true in rails 1.2.3 (my  
actual version) but not in rails 1.2.6 (my target version).  
If anybody has some explanations, the only thing related I see in  
active record changelog is on version 1.15.6

- Fix has\_many :through delete with custom foreign keys. #6466  
[naffis]

Thanks in advance  
Niko
