I'm trying to use this solution to get the dimensions of an image. In development works great, but in staging (using fog) with img = ::Magick::Image::read(@file.file).first
throws me:
private method 'file' called for #<CarrierWave::Storage::Fog::File:0x00000008fe28d0>
How can I retrieve the file with fog?
Update:
I'm using carrirwave_backgrounder
to process the images asynchronously. This is part of the code:
# the uploader
def geometry
@geometry ||= get_geometry
end
def get_geometry
if(@file)
img = ::MiniMagick::Image.open(@file.file)
@geometry = {width: img[:width], height: img[:height]}
end
end
# the model
mount_uploader :image, ImageUploader
process_in_background :image
before_save :set_dimensions
def set_dimensions
geometry = self.image.geometry
self.width = geometry[:width]
self.height = geometry[:height]
end
I've figured out that the error appears just when I update the model, not when this is created, so I've changed the callback to before_create :set_dimensions
and works fine. I suppose it could be because when I'm updating, the file is just in the assets host, but is just a guessing.