Gem carrierwave 使用 recreate_versions! 这个方法报错

zhg · 2016年10月13日 · 1653 次阅读

执行 ProductImage.last.picture_url.recreate_versions!

返回错误:TypeError: no implicit conversion of nil into String

rvm/gems/ruby-2.3.0@camp/gems/carrierwave-0.10.0/lib/carrierwave/uploader/cache.rb:83:in `initialize'

class ProductImageUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick
  include Concerns::Uploader

  if CarrierwaveSetting.status == 'open'
    storage CarrierwaveSetting.storage.to_sym
  else
    storage :file
  end

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  def filename
    original_filename
  end

  version :thumb_500_500 do
    process resize_and_pad: [500, 500]
  end

  def extension_white_list
    %w{bmp png jpeg jpg gif}
  end

  def store_from_url(url)
    file_path = Aliexpress::Image.download url

    File.open file_path do |file|
      self.store! file
    end
  end
end
zhg 关闭了讨论。 03月21日 22:40
需要 登录 后方可回复, 如果你还没有账号请 注册新账号