Question

I use paperclip for the attachments on my models. I've recently added a fingerprint to the attachments, it works fine with the new attachments but it ws not added to the old ones, because of this I'm having trouble reprocessing attachments to add a new style, because paperclip tries to find the attachments with fingerprint and not all the attachments have one.

Is there a way to add the fingerprint to the old attachments?

This is the error I'm getting from the reprocessing on the old attachments:

Errno::ENOENT: No such file or directory - /tmp/paperclip-reprocess20140422-1036-nl9gxk
Was it helpful?

Solution 2

After manually try and examine the error several times I found that the problem is not that the attachment had no fingerprint. The problem was that the fingerprint was nil. For some reason paperclip does not handle this case.

I manually gave every object an empty string as a fingerprint through the database (this saved me from renaming the file on disk) and then reprocess every one of theme.

That solved it!

OTHER TIPS

[edit] Have you tried?

$ rake paperclip:refresh class=Model_Name_Goes_Here

[/edit]

if you don't have too many images. simplest way, I can think of is:

Dir.foreach('/path/to/dir/that/contains/old/images') do |item|
  next if item == '.' or item == '..'
  file = File.join(File.expand_path(File.dirname(__FILE__)), item)
  thing.image = file
  thing.save
end

you can run this script, using runner:

$ rails runner /path/to/script

Does something like this work for you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top