Paperclip Image Versioning

Hello. I’m hoping to hear your recommendations on using paperclip for
images with versioning.

Anyone know of any elegant paper_clip image, versioning implementation
solutions?

Thank you

Not elegant, but I did manage to get Paperclip to stop deleting or
overwriting the previous versions’ attachments (I am using
vestal_versions here for that part). The path I took was to patch
attachment.rb and storage.rb from Paperclip. In attachment, I look to
see if the instance was versioned, and if it was I would inject the
version number into the filename before Paperclip saved it. In the
same file, I patched the clear method to never delete an instance that
was versioned.

In storage.rb, I did the reverse, and let the flush_deletes method
remove a non-empty folder.

Both of these changes are fairly risky, in that they require the
parent model to have a version method, which I ended up having to
provide like this:

def version
false
end

in anything that had a file attachment but didn’t have versions. I’m
pretty sure this could be improved on a lot.

Walter

Thanks Walter, I appreciate the quick reply…

To your points, would highly like to avoid messing with paperclip or
vestal_versions.

What about creating a customer model to store photo versions like
PHOTO_VERSIONS

And then on any update, manually copy the previous photo record over
to PHOTO_VERSIONS?

Only thing I’m not sure about is paperclip would still delete the
photo from S3, so I’d have to recreate the photo? idk, it’s getting
messy.

Thoughts anyone?