# Paperclip attachment destroy

**URL:** <https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546>\
**Category:** Rails\
**Created:** [September 14, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546 "2008-09-14T18:54:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [September 14, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546/1 "2008-09-14T18:54:42Z")

</div>

Hi all

I’ve got a problem with the paperclip-plugin.  
Is it posible that the attachment is not destroy if i call the  
destroy-  
method of a model?  
Thank you for your help!

sigma

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [September 16, 2008, 8:00am UTC](https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546/2 "2008-09-16T08:00:55Z")

</div>

Hi  
Has nobody an idea how this could work?

sigma

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [September 20, 2008, 2:51pm UTC](https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546/3 "2008-09-20T14:51:28Z")

</div>

Christoph Thommen wrote:

> Hi  
> Has nobody an idea how this could work?
> 
> sigma

Hi sigma

I haven’t noticed this. You may want to post in the Paperclip google  
group to see what they say. If you’re really worried, maybe you could do  
a before\_destroy callback on the model and set its attachment attribute  
to nil (or call @model.attachment.destroy) - that should do the trick.  
But I bet that the attachment probably is being destroyed, I would’ve  
thought it should be default behaviour by Paperclip…

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [February 13, 2009, 1:28pm UTC](https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546/4 "2009-02-13T13:28:12Z")

</div>

(or call @model.attachment.destroy) - that should do the trick.

Doesn’t work.

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [February 13, 2009, 2:04pm UTC](https://www.ruby-forum.com/t/paperclip-attachment-destroy/148546/5 "2009-02-13T14:04:38Z")

</div>

Colorblind wrote:

> (or call @model.attachment.destroy) - that should do the trick.
> 
> Doesn’t work.

@model.destroy will destroy both the object and file from your storage  
system. If it does not, it means you have customized somewhere the  
behavior of the attachment. Using debugger should help you out and check  
out thoroughly your log files.
