olympiamanagement/app/models/olympia_images_uploader.rb

29 lines
717 B
Ruby
Raw Permalink Normal View History

2020-02-03 15:24:43 +00:00
# encoding: utf-8
2020-02-04 11:24:13 +00:00
require 'carrierwave/orm/activerecord'
2020-02-03 15:24:43 +00:00
class OlympiaImagesUploader < CarrierWave::Uploader::Base
2020-02-04 11:24:13 +00:00
include CarrierWave::MiniMagick
2020-02-03 15:24:43 +00:00
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
2020-02-04 11:24:13 +00:00
storage :file
2020-02-03 15:24:43 +00:00
# storage :s3
# 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-02-04 16:37:03 +00:00
return "uploads/#{model.class.to_s.underscore}/olympia_students/#{model.id}/"
2020-02-03 15:24:43 +00:00
end
# override
def filename
@original_filename
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end