Preventing Paperclip from deleting/overwriting attachments on update

后端 未结 4 921
灰色年华
灰色年华 2020-12-30 01:39

I\'m having a hard time figuring out how to prevent Paperclip from deleting the old version of an attachment (image).

I have a model, Site, which has an attachment,

4条回答
  •  臣服心动
    2020-12-30 02:21

    There's a new option that tells paperclip to preserve old attachments:

    https://github.com/thoughtbot/paperclip/commit/65e8d4f6de50732d8e1b https://github.com/thoughtbot/paperclip/issues/60

    Simple to use:

    has_attached_file => :attachment,
                         :styles => { :thumb => 100x100! },
                         :preserve_files => true
    

    It's not documented yet and took some digging to find so I wanted to share it here.

提交回复
热议问题