Reading uploaded image: undefined method `file' for nil:NilClass

守給你的承諾、 提交于 2019-12-11 13:51:30

问题


I receive the following error when I try to get image during thumbnail creation:

undefined method `file' for nil:NilClass

My code:

  version :thumb do
      img = ::Magick::Image::read(@file.file).first
      w = img.columns
      h = img.rows

      if w < h
        process :resize_to_limit => [30, 50]
      else
        process :resize_to_limit => [50, 30]
      end
  end

Any ideas what is this not working?

来源:https://stackoverflow.com/questions/24363366/reading-uploaded-image-undefined-method-file-for-nilnilclass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!