Carrierwave调整大小不起作用(Rails 3和MiniMagick)

Joh*_*ohn 4 resize process carrierwave minimagick

我想要做的是通过IMGKit保存一个带有全尺寸快照的网站网址.在其中一个视图中,我还想拥有快照的缩略图版本.我正在使用carrierwave将快照与MiniMagick对象关联起来操作它,问题是它生成了'thumbnail'图像但没有调整它的大小,因此我有两个全尺寸的快照,其中一个用'thumb'作为前缀.

我在轨道上有这个型号

class Webpage
  mount_uploader :snapshot, SnapshotUploader
  field :url, type: String
  field :title, type: String

  after_create :get_snapshot

  private
  def get_snapshot
    file = Tempfile.new(["#{id}#{title}".downcase, '.jpg'], 'tmp', :encoding => 'ascii-8bit')
    image = IMGKit.new(url, quality: 90).to_jpg
    file.write(image)
    file.flush
    self.snapshot= file
    self.save
    file.unlink
  end


end
Run Code Online (Sandbox Code Playgroud)

我在上传器中有这个以创建缩略图版本:

class SnapshotUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick

  version :thumb do
    process resize_to_fill: [180, 180]
  end

end
Run Code Online (Sandbox Code Playgroud)

使用控制台我尝试使用MiniMagick来调整图像大小并且工作正常儿子我不知道发生了什么.我不确定我是否做得对,所以任何帮助都会受到赞赏.谢谢.

Joh*_*ohn 18

好的,我很蠢.我有一个初始化器

config.enable_processing = false
Run Code Online (Sandbox Code Playgroud)

所以它永远不会处理图像.只需将其设置为true或删除该行即可解决我的问题.