1

使用 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

问题是拇指、迷你和中型版本可以正确保存自己,但没有调整大小(所有版本的大小都相同)。

有人遇到类似的事情吗?

4

1 回答 1

0

好的,只是想通了....经过 4 小时的调试!

我使用的 ruby​​ 1.9.2 与 minimagick 的调整大小不兼容一旦我升级到 ruby​​ 1.9.3 一切都恢复正常并且调整大小工作完美。

这应该清楚地记录在案。

于 2013-08-19T03:15:33.090 回答