Ruby on rails Carrierwave版本取决于文件扩展名

Ruby on rails Carrierwave版本取决于文件扩展名,ruby-on-rails,carrierwave,Ruby On Rails,Carrierwave,我有一个上传器 class PimageUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick storage :webdav if Rails.env.production? storage :file if Rails.env.development? version :preview do process resize_to_limit: [640, 640] en

我有一个上传器

class PimageUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick

  storage :webdav if Rails.env.production?
  storage :file if Rails.env.development?

  version :preview do
    process resize_to_limit: [640, 640]
  end

  version :post do
    process resize_to_limit: [640, nil]
  end

  version :thumb do
    process resize_to_limit: [150, nil]
  end

end
类PimageUploader
帮帮我,我需要使用扩展名gif make only thumb版本进行归档。

尝试以下操作:

  version :thumb, :if => :is_gif?

  protected
  def is_gif?(picture)
    picture.extension.to_s.downcase == 'gif'
  end