# Will acts\_as\_paranoid work with attachment\_fu?

**URL:** <https://www.ruby-forum.com/t/will-acts-as-paranoid-work-with-attachment-fu/149525>\
**Category:** Rails\
**Created:** [September 25, 2008, 7:49pm UTC](https://www.ruby-forum.com/t/will-acts-as-paranoid-work-with-attachment-fu/149525 "2008-09-25T19:49:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [September 25, 2008, 7:49pm UTC](https://www.ruby-forum.com/t/will-acts-as-paranoid-work-with-attachment-fu/149525/1 "2008-09-25T19:49:23Z")

</div>

I’ve got a problem in that users are deleting a paranoid model through  
the application, including dependents. Some of these dependents are  
paranoid too, but not the attachments. (I’m using DB file storage.) I  
need to be able to un-delete these things and I’m now wondering if  
acts\_as\_paranoid will work with models that use attachment\_fu? If so, in  
what model to I add the acts\_as\_paranoid bit, and do I need to override  
the acts\_as\_attachment model destroy methods?

class Project \< ActiveRecord::Base  
has\_many :supporting\_documents, :as =\> :documentable, :dependent =\>  
:destroy  
has\_many :jobs, :dependent =\> :destroy  
has\_many :comments, :as =\> :resource, :order =\> ‘created\_at desc’,  
:dependent =\> :destroy  
has\_many :documents  
acts\_as\_paranoid  
end

class Job \< ActiveRecord::Base  
belongs\_to :project  
acts\_as\_paranoid  
end

class Comment \< ActiveRecord::Base  
acts\_as\_paranoid  
belongs\_to :resource, :polymorphic =\> true  
end

class Document \< ActiveRecord::Base

# we need to upload efax documents, they have no mime type, so we have

to allow application/octet-stream  
has\_attachment :content\_type =\> [:image, ‘application/pdf’,  
‘application/msword’, ‘text/plain’, ‘application/vnd.ms-excel’,  
‘application/msexcel’, ‘application/octet-stream’],  
:max\_size =\> 5.megabytes

belongs\_to :documentable, :polymorphic =\> true

validates\_as\_attachment  
end

class SupportingDocument \< Document  
end

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [September 26, 2008, 12:12am UTC](https://www.ruby-forum.com/t/will-acts-as-paranoid-work-with-attachment-fu/149525/2 "2008-09-26T00:12:46Z")

</div>

I poked around and figured this out myself. I had to add the following  
to my document model:

class Document \< ActiveRecord::Base  
…

acts\_as\_paranoid

#do not destory file (usually called from after\_destroy)  
def destroy\_file  
return  
end  
end

Chris B. wrote:

> I’m now wondering if  
> acts\_as\_paranoid will work with models that use attachment\_fu? If so, in  
> what model to I add the acts\_as\_paranoid bit, and do I need to override  
> the acts\_as\_attachment model destroy methods?
