# Dependency

**URL:** <https://www.ruby-forum.com/t/dependency/137782>\
**Category:** Rails\
**Created:** [May 16, 2008, 10:24am UTC](https://www.ruby-forum.com/t/dependency/137782 "2008-05-16T10:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [May 16, 2008, 10:24am UTC](https://www.ruby-forum.com/t/dependency/137782/1 "2008-05-16T10:24:58Z")

</div>

Hello!

My problem is my :dependent =\> :destroy do not call the destroy method.  
Why is it so?  
Any sugesstions.

class Comment  
belongs\_to :commentable, :polymorphic =\> true,  
end

class Article  
has\_many :comments, :as =\> ‘commentable’, :dependent =\> :destroy  
end

---

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [May 16, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/dependency/137782/2 "2008-05-16T12:30:47Z")

</div>

In my opinion:

If you call delete method, then it will not call destroy method,  
if you call destroy method, it will call destroy method.

i.e.  
Article.destroy

it is the discrepancy between delete and destroy method.

---

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [May 16, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/dependency/137782/3 "2008-05-16T12:30:49Z")

</div>

In my opinion:

If you call delete method, then it will not call destroy method,

if you call destroy method, it will call destroy method.

i.e.

Article.destroy

it is the discrepancy between delete and destroy method.

On Fri, May 16, 2008 at 4:24 PM, Mikael BjÃ¶rkegren \<  
removed\_email\_address@domain.invalid\> wrote:

> ## class Article has\_many :comments, :as =\> ‘commentable’, :dependent =\> :destroy end
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Nibirutech CTO Eric.Archangel  
MSN: removed\_email\_address@domain.invalid  
QQ: 996252  
GMAIL: removed\_email\_address@domain.invalid  
BLOG: [archangel\_新浪博客](http://blog.sina.com.cn/gameloft)

---

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [May 16, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/dependency/137782/4 "2008-05-16T14:00:26Z")

</div>

Thanks for your reply.  
But it do not call my destroy method for Comment, but it removes it  
from my database. ?

Eric.Archangel wrote:

> In my opinion:
> 
> If you call delete method, then it will not call destroy method,  
> if you call destroy method, it will call destroy method.  
> Article.destroyï¿½
