Class: BaseUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick
Defined in:
app/uploaders/base_uploader.rb

Direct Known Subclasses

AvatarUploader, PhotoUploader

Instance Method Summary collapse

Instance Method Details

#default_urlObject

Provide a default URL as a default if there hasn't been a file uploaded:


12
13
14
# File 'app/uploaders/base_uploader.rb', line 12

def default_url
  "photo/#{version_name}.jpg"
end

#extension_white_listObject

Add a white list of extensions which are allowed to be uploaded. For images you might use something like this:


18
19
20
# File 'app/uploaders/base_uploader.rb', line 18

def extension_white_list
  %w(jpg jpeg gif png)
end

#store_dirObject

Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted:


7
8
9
# File 'app/uploaders/base_uploader.rb', line 7

def store_dir
  "#{model.class.to_s.underscore}"
end