2014-03-23 00:22:25 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
class FileUploader < CarrierWave::Uploader::Base
|
|
|
|
# Override the directory where uploaded files will be stored.
|
|
|
|
# This is a sensible default for uploaders that are meant to be mounted:
|
|
|
|
def store_dir
|
2020-04-02 02:51:37 +00:00
|
|
|
if model and model.directory
|
2020-04-06 20:54:10 +00:00
|
|
|
# This is a recursive look up
|
2020-04-02 02:51:37 +00:00
|
|
|
model.directory.full_path
|
|
|
|
else
|
|
|
|
Directory.find(Directory::ROOT).full_path
|
|
|
|
end
|
2020-04-01 02:00:53 +00:00
|
|
|
# .gsub(/public\//, '')
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Provide a default URL as a default if there hasn't been a file uploaded:
|
|
|
|
# def default_url
|
|
|
|
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
|
|
|
# end
|
|
|
|
end
|