使用 Rails 3.2.12 和 Ruby 1.9.2 我只是想像这样使用carrierwave/minimagick:
在我的 Gemfile
gem 'carrierwave'
gem 'mini_magick'
在我的上传器中
require 'carrierwave/processing/mini_magick'
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
# # For Rails 3.1+ asset pipeline compatibility:
ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
end
process :resize_to_fit => [800, 800]
version :thumb do
process :resize_to_fit => [200,200]
end
version :mini do
process :resize_to_fit => [50,50]
end
version :medium do
process :resize_to_fit => [250,250]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
问题是拇指、迷你和中型版本可以正确保存自己,但没有调整大小(所有版本的大小都相同)。
有人遇到类似的事情吗?