Kevin Whitaker
Kevin Whitaker

Reputation: 13425

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?

Upvotes: 6

Views: 1618

Answers (2)

notrehtad
notrehtad

Reputation: 11

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

Upvotes: 1

Kevin Sylvestre
Kevin Sylvestre

Reputation: 38032

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.

Upvotes: 7

Related Questions