how to keep old versions of attachment files

22 views
Skip to first unread message

Alain Ravet

unread,
Jun 29, 2009, 1:27:46 PM6/29/09
to Paperclip Plugin
Hi all,

When you update (replace) the attachment associated to an AR object,
all the files (styles) associated to the old attachment are wiped-out
from the server.
Is there a clean way to keep those old files?

Usecase : images in emails.
We send notifications by emails and they include images (ex: users
avatars). If an image is updated at a later time on the server (ex: a
user changes his avatar), we don't want those emails to look broken
because the old images files don't exist anymore.


This behaviour is caused by the self.clean in Attachment.assign

file attachment.rb, line 74

def assign uploaded_file
...
self.clear <<<--------- erases the old files
...
end

I couldn't find an option nor a call back to change this behaviour.

TIA


Alain

Alain Ravet

unread,
Jul 10, 2009, 9:13:46 PM7/10/09
to Paperclip Plugin
has_attached_file :avatar,
:keep_old_files => true

There is an associated ticket :
http://github.com/thoughtbot/paperclip/issues#issue/60

A patch is available at :
http://github.com/alainravet/paperclip/tree/keep_old_files


Any comments?

Alain Ravet

unread,
Jul 18, 2009, 3:27:08 PM7/18/09
to Paperclip Plugin
guys,

Does the patch needs more work?
Who to send the pull request to?

Alain

Jonathan Yurek

unread,
Jul 28, 2009, 2:50:23 PM7/28/09
to papercli...@googlegroups.com
Hi,

Thanks for the patch. I haven't had a chance to get around to checking
patches and github issues recently, but I will be able to review it
soon.
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
organic brains. digital solutions.

617.482.1300 x114
http://www.thoughtbot.com/

Reply all
Reply to author
Forward
0 new messages