2017-05-01 09:14:35 -04:00
|
|
|
class PersonalFileUploader < FileUploader
|
|
|
|
def self.dynamic_path_segment(model)
|
|
|
|
File.join(CarrierWave.root, model_path(model))
|
|
|
|
end
|
|
|
|
|
2017-06-27 06:53:06 -04:00
|
|
|
def self.base_dir
|
2017-08-07 13:43:11 -04:00
|
|
|
File.join(root_dir, '-', 'system')
|
2017-06-27 06:53:06 -04:00
|
|
|
end
|
|
|
|
|
2017-05-01 09:14:35 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def secure_url
|
|
|
|
File.join(self.class.model_path(model), secret, file.filename)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.model_path(model)
|
2017-05-03 11:26:49 -04:00
|
|
|
if model
|
|
|
|
File.join("/#{base_dir}", model.class.to_s.underscore, model.id.to_s)
|
|
|
|
else
|
|
|
|
File.join("/#{base_dir}", 'temp')
|
|
|
|
end
|
2017-05-01 09:14:35 -04:00
|
|
|
end
|
|
|
|
end
|