How to check if there is a version of the image on S3 with Carrierwave and Fog?

I upload my images using Carrierwave and Fog to S3. When loading, I also create a thumbnail version of the image:

version :thumb do process :resize_to_limit => [90, 80], if: :is_resizable? end 

Now I need a method for checking the version of the thumbnails.

The documentation specifies the exists? . This really works if I want to check for the original version:

 asset.file.exists? # => true 

But when I use a "big" version like this:

 asset.url(:thumb).file.exists? 

he receives:

undefined method 'exists?' for #<String:0x007fcd9f9d9620> undefined method 'exists?' for #<String:0x007fcd9f9d9620> :

+7
ruby-on-rails amazon-s3 carrierwave fog
source share
2 answers

Use this:

 asset.thumb.file.exists? 

instead: asset.url(:thumb).file.exists?

+17
source share

Correct answer:

 asset.file.thumb.file.exists? 

where file = installed_uploader and asset = model

+1
source share

All Articles