Created
January 12, 2017 14:42
-
-
Save chuyihuang/5ccf46d1cda5b66fa88b53166b38b867 to your computer and use it in GitHub Desktop.
carrierwave uploader example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PictureUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
storage :file | |
def store_dir | |
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" | |
end | |
version :thumb do | |
process :resize_to_fill => [40, 30] | |
process quality: 70 | |
end | |
version :small do | |
process :resize_to_fill => [187, 205] | |
# process quality: 90 | |
end | |
def extension_white_list | |
%w(jpg jpeg gif png) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment