Paperclip弃用方法

Ram*_*aja 3 ruby ruby-on-rails paperclip ruby-on-rails-3

我将rails应用程序升级rails 2.3.14rails 3.2.6.在我的模型中,我有以下方法从我的视图中调用以进行图像编辑.

def logo_geometry(style = :original)
  @geometry ||= {}
  @geometry[style] ||= Paperclip::Geometry.from_file(logo.to_file(style)) # works with s3
end
Run Code Online (Sandbox Code Playgroud)

当调用此方法后发生错误.

undefined method `to_file' for #<Paperclip::Attachment:0xd9d06e0>
Run Code Online (Sandbox Code Playgroud)

任何实现to_file方法功能的建议??

Ram*_*aja 8

回答我自己的问题.

替换logo.to_file(style) Paperclip.io_adapters.for(logo.styles[style]).

所以方法将是这样的..

def logo_geometry(style = :original)
  @geometry ||= {}
  @geometry[style] ||= Paperclip::Geometry.from_file(Paperclip.io_adapters.for(logo.styles[style])) 
end
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.回形针现在开始让我烦恼. (2认同)