首页 > 代码库 > carrierwave mount uploader 的位置问题,奇怪

carrierwave mount uploader 的位置问题,奇怪

  ### callbacks  before_save :assign_qr_code  ### mount uploader  mount_uploader :qr_code_image, QrCodeUploader  # 上面这两行代码换位置就不行了,为啥?  private  def assign_qr_code      if self.qr_code_image.url == nil          tmp_path = Rails.root.join(tmp, "qrcode.png")      png = RQRCode::QRCode.new( qrcode_url, :size => 4, :level => :h ).to_img.resize(250, 250).save(tmp_path)        File.open(tmp_path) do |file|          self.qr_code_image = file        end        File.delete(tmp_path)    end  end  def qrcode_url    "http://hi.baidu.com"  end

 

carrierwave mount uploader 的位置问题,奇怪