Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip deprecated method

I upgraded my rails app from rails 2.3.14 to rails 3.2.6. In my model i have the following method that is being called from my view for image editing purpose.

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

when this method is called following error occurs.

undefined method `to_file' for #<Paperclip::Attachment:0xd9d06e0>

Any suggestion to achieve the functionality of to_file method??

like image 639
Ramiz Raja Avatar asked Jan 14 '23 19:01

Ramiz Raja


1 Answers

Answer to my own question.

replace logo.to_file(style) with Paperclip.io_adapters.for(logo.styles[style]).

so method will be be like this..

def logo_geometry(style = :original)
  @geometry ||= {}
  @geometry[style] ||= Paperclip::Geometry.from_file(Paperclip.io_adapters.for(logo.styles[style])) 
end
like image 93
Ramiz Raja Avatar answered Jan 22 '23 05:01

Ramiz Raja