ruby on rails 3 - Accessing to an image instance with carrierwave and fog -
i'm trying use this solution dimensions of image. in development works great, in staging (using fog) img = ::magick::image::read(@file.file).first
throws me: private method 'file' called #<carrierwave::storage::fog::file:0x00000008fe28d0>
how can retrieve file fog?
update:
i'm using carrirwave_backgrounder
process images asynchronously. part of code:
# 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 # 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 error appears when update model, not when created, i've changed callback before_create :set_dimensions
, works fine. suppose because when i'm updating, file in assets host, guessing.
change file
url
, be:
img = ::minimagick::image.open(@file.url)
Comments
Post a Comment