# Before\_destroy not called

**URL:** <https://www.ruby-forum.com/t/before-destroy-not-called/55883>\
**Category:** Rails\
**Created:** [March 24, 2006, 3:15pm UTC](https://www.ruby-forum.com/t/before-destroy-not-called/55883 "2006-03-24T15:15:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [March 24, 2006, 3:15pm UTC](https://www.ruby-forum.com/t/before-destroy-not-called/55883/1 "2006-03-24T15:15:55Z")

</div>

Hello, I’m trying to intercept delete call in my model but  
before\_destroy callback is never called…

Somebody knows why ?

Thanks

The controller :

def delete  
Image.delete(params[:id])  
redirect\_to :action =\> “list”  
end

The model :  
class Image \< ActiveRecord::Base  
set\_table\_name “publish\_images”  
belongs\_to :article  
before\_destroy :on\_destroy

def delete  
end

def on\_destroy  
breakpoint # never hit this bkpoint  
end  
end

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [March 24, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/before-destroy-not-called/55883/2 "2006-03-24T18:00:57Z")

</div>

before destroy is called before the destroy() method is called. you’re  
not  
calling destroy.

try this instead:

The controller :

def delete  
Image.destroy(params[:id])  
redirect\_to :action =\> “list”  
end

The model :  
class Image \< ActiveRecord::Base  
set\_table\_name “publish\_images”  
belongs\_to :article  
before\_destroy :on\_destroy

private  
def on\_destroy  
breakpoint # never hit this bkpoint  
end  
end

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [March 25, 2006, 11:45am UTC](https://www.ruby-forum.com/t/before-destroy-not-called/55883/3 "2006-03-25T11:45:51Z")

</div>

Fine - I didn’t noticed the difference between destroy and delete, I  
tought destroy was an alias to delete.

Thanks a lot !
