recreate versions - carrierwave-fog-aws
Asked Answered
U

1

13

I'm trying to recreate the images that I have uploaded using the following in my model...

  Post.all.each do |ym| 
      ym.avatar.cache_stored_file! 
      ym.avatar.retrieve_from_cache!(ym.avatar.cache_name) 
      ym.avatar.recreate_versions! 
      ym.save! 
  end

Unfortunately, I get the following error....

(undefined method `body' for nil:NilClass):

My uploader is named AvatarUploader and is for my Post model. Any advice on how to fix this?

Undercast answered 15/4, 2013 at 23:32 Comment(3)
I think you are supposed to put that code in the uploader and not the Post model.Steamer
Can you add a backtrace?Hemostat
Is it on a read-only server?Newsom
N
0

I've ran with a similar problem when using async processing on a read-only server(Heroku). In my case there was a problem when defining file size which I resolved monkey-patching def size from fog file class:

module CarrierWave
  module Storage
    class Fog < Abstract
      class File
        def size
          file.nil? ? 0 : file.content_length
        end
      end
    end
  end
end

I could help you more if the issue still persists and when you post more details from your backtrace and gems configuration.

Newsom answered 15/2, 2018 at 15:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.