photomix/app/uploaders/userpic_uploader.rb
2012-07-27 00:26:23 +04:00

28 lines
700 B
Ruby

class UserpicUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def store_dir
"#{ENV['STORAGE_PATH']}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/original"
end
def filename
"#{::SecureRandom.hex(8)}#{File.extname(original_filename).downcase}" if original_filename
end
version :mini do
process :resize_to_fit => [50, 50]
def store_dir
"#{ENV['STORAGE_PATH']}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/mini"
end
end
version :small do
process :resize_to_fit => [100, 100]
def store_dir
"#{ENV['STORAGE_PATH']}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/small"
end
end
end