문제

I'm uploading my images with Carrierwave and Fog to S3. On the upload 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 to check if thumbnail version exists.

The Documentation lists the exists? method. This actually works, if I want to check the existence of the original version:

asset.file.exists? # => true

But when I use the "thumb" version like this:

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

it get:

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

도움이 되었습니까?

해결책

Use this:

asset.thumb.file.exists?

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

다른 팁

The correct answer is:

asset.file.thumb.file.exists?

where file = mounted_uploader and asset = model

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top