# Attachment\_fu file deletion

**URL:** <https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961>\
**Category:** Rails\
**Created:** [June 27, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961 "2007-06-27T21:43:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 27, 2007, 9:43pm UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/1 "2007-06-27T21:43:51Z")

</div>

I was wondering if there was a built in function for deleting non-image  
files?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 12:04am UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/2 "2007-06-28T00:04:03Z")

</div>

On 6/27/07, Daniel G [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I was wondering if there was a built in function for deleting non-image  
> files?

The attachment model gets callbacks for removing thumbnails and the  
actual file:

[http://bs.techno-weenie.net/!source/2923/plugins/attachment\_fu/lib/technoweenie/attachment\_fu.rb#72](http://bs.techno-weenie.net/!source/2923/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb#72)

So, delete the model and it should clean up the file(s) for you.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 12:23am UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/3 "2007-06-28T00:23:28Z")

</div>

Sorry, I’m new to rails…  
When you say model, do you mean the database entry?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 12:46am UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/4 "2007-06-28T00:46:18Z")

</div>

Ok thanks, I got it

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 1:42am UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/5 "2007-06-28T01:42:28Z")

</div>

th8254 wrote:

> Ok thanks, I got it

Guess I don’t; I have this link:  
\<%= link\_to “delete”, { :action =\> “delete” }, :confirm =\> “Are you  
sure?” %\>  
but when I click on it leads me to a blank page  
[http://localhost:3000/files/delete](http://localhost:3000/files/delete)

The action looks like this:  
def delete  
@user.file.destroy  
flash[:notice] = ‘Your file has been deleted.’  
redirect\_to hub\_url  
end

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 1:58am UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/6 "2007-06-28T01:58:30Z")

</div>

Thanks, took a second look at my routes and found the error

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 28, 2007, 1:51am UTC](https://www.ruby-forum.com/t/attachment-fu-file-deletion/107961/7 "2007-06-28T01:51:10Z")

</div>

On 6/27/07, th8254 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The action looks like this:  
> def delete  
> @user.file.destroy  
> flash[:notice] = ‘Your file has been deleted.’  
> redirect\_to hub\_url  
> end

That’s a problem with your routes or your controller, not  
attachment\_fu. Look at your logs and see why it’s a blank screen.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
