CarrierWave Image URL

I have a model that has:

    mount_uploader :image, ImageUploader

When loading an image, I want to get some width, height and some EXIF ​​data from the image. In the previous filter, I call self.image.url, but this will return something like:

/uploads/tmp/20110630-1316-10507-7899/emerica_wildinthestreets.jpg

The problem is that when I try to open this image using:

image = MiniMagick::Image.open(self.image.url)

I get "There is no such file or directory - / uploads / tmp / 20110630-1312-10507-6638 / emerica_wildinthestreets.jpg" . It seems that the image has already been transferred from the tmp folder to the final location, but self.image.urldoes not reflect this change.

I also tried this in a method after_save, but the result is the same. Any ideas?

+5
source share
1 answer

Turns out I needed to add "# {Rails.root.to_s} / public /" to self.image.url

+5
source

All Articles