开发者

Rails Paperclip - skip attachment saving

开发者 https://www.devze.com 2023-01-30 18:02 出处:网络
开发者_开发技巧Is there a way to tell paperclip to skip saving attachments in certain cases?I\'m running some background tasks that update a model with paperclip files attached, and it re-saves those
开发者_开发技巧

Is there a way to tell paperclip to skip saving attachments in certain cases? I'm running some background tasks that update a model with paperclip files attached, and it re-saves those attachments after every save. Is there anyway to bypass this?


Paperclip only performs an actual save (i.e. deletes old attachment and writes new attachment) if you update the attachement, but will log [paperclip] saving attachment every time a model is saved. It does this because the log message is printed in an after_save call back (before it loops through all attachments and flushes any pending writes or deletes). Provided that you aren't assigning a new attachment, you can ignore the saving attachment message.


You could use Paperclip.options[:log] = false ... (from here). Better late than never?

0

精彩评论

暂无评论...
验证码 换一张
取 消