Class: AssetUploader

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

Direct Known Subclasses

DocumentUploader, ImageUploader

Instance Method Summary collapse

Instance Method Details

#set_md5Object

Set an MD5 hash of the image



22
23
24
25
26
# File 'app/uploaders/asset_uploader.rb', line 22

def set_md5
  if model.present?
    model.checksum = Digest::MD5.file(current_path).to_s
  end 
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:



13
14
15
16
17
18
19
# File 'app/uploaders/asset_uploader.rb', line 13

def store_dir
  if model.present?
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  else
    "uploads/#{mounted_as}"
  end
end