Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Paperclip - skip attachment saving

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?

like image 772
Kevin Whitaker Avatar asked Dec 16 '10 15:12

Kevin Whitaker


2 Answers

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.

like image 76
Kevin Sylvestre Avatar answered Oct 30 '22 08:10

Kevin Sylvestre


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

like image 38
notrehtad Avatar answered Oct 30 '22 09:10

notrehtad