Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CarrierWave Image URL

I have a model that has:

    mount_uploader :image, ImageUploader

When uploading an Image I want to retrieve some width, height and some EXIF data from the image. In a before filter I am calling 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 "No such file or directory - /uploads/tmp/20110630-1312-10507-6638/emerica_wildinthestreets.jpg". It seems like the image has already been moved from the tmp folder to it's final location but self.image.url is not reflecting this change.

I've also tried this in an after_save method but the result is the same. Any ideas?

like image 599
Kyle Decot Avatar asked Jun 30 '11 17:06

Kyle Decot


1 Answers

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

like image 134
Kyle Decot Avatar answered Sep 26 '22 08:09

Kyle Decot