Attachment_fu: how to remove images?

I just used attachment_fu for the first time, and it works quite well.
I have a user-model, and each of them has_one :image (and the images
belongs_to :user). I have a question on this though: how can i remove
images? Whenever i set a new image for a user (a user who already has
an image), then the table with images gets updated correctly, with the
user_id column of the old image set to null, and the new image then
has the correct user_id.

What i want is ofcourse to remove the old image (which has no
references to any user anymore) from the database and the filesystem,
and the same for the thumbnail that was created with it.

Does attachment_fu have methods for this?

Peter wrote:

What i want is ofcourse to remove the old image (which has no
references to any user anymore) from the database and the filesystem,
and the same for the thumbnail that was created with it.

Does attachment_fu have methods for this?

Did you try: user.image.destroy or user.image.delete (bypass
callbacks?)

hth

ilan

That works quite good. I have the feeling i should’ve known or at
least tried that :slight_smile:

Thank you!

On Feb 23, 8:29 pm, Ilan B. [email protected]

Peter wrote:

That works quite good. I have the feeling i should’ve known or at
least tried that :slight_smile:

Thank you!

On Feb 23, 8:29 pm, Ilan B. [email protected]

No worries at all, I can’t count the times I got an answer and then
proceeded to smack my head on the desk!

ilan