fix attachment uploader for aws

This commit is contained in:
Dmitriy Zaporozhets 2013-02-11 10:14:32 +02:00
parent 2d83e43db0
commit ab19196391

View file

@ -8,6 +8,15 @@ class AttachmentUploader < CarrierWave::Uploader::Base
end
def image?
%w(png jpg jpeg).include?(file.extension)
img_ext = %w(png jpg jpeg)
if file.respond_to?(:extension)
img_ext.include?(file.extension)
else
# Not all CarrierWave storages respond to :extension
ext = file.path.split('.').last
img_ext.include?(ext)
end
rescue
false
end
end