Module: UploaderHelper

Included in:
AttachmentUploader, AvatarUploader, FileUploader
Defined in:
app/uploaders/uploader_helper.rb

Overview

Extra methods for uploader

Instance Method Summary collapse

Instance Method Details

#file_storage?Boolean

Returns:

  • (Boolean)

16
17
18
# File 'app/uploaders/uploader_helper.rb', line 16

def file_storage?
  self.class.storage == CarrierWave::Storage::File
end

#image?Boolean

Returns:

  • (Boolean)

3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/uploaders/uploader_helper.rb', line 3

def image?
  img_ext = %w(png jpg jpeg gif bmp tiff)
  if file.respond_to?(:extension)
    img_ext.include?(file.extension.downcase)
  else
    # Not all CarrierWave storages respond to :extension
    ext = file.path.split('.').last.downcase
    img_ext.include?(ext)
  end
rescue
  false
end