首页 > 其他 > 详细

carrierwave mount uploader 的位置问题,奇怪

时间:2014-10-14 14:13:49      阅读:169      评论:0      收藏:0      [点我收藏+]
  ### 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 的位置问题,奇怪

原文:http://www.cnblogs.com/laoquans/p/4024206.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!