Skip to content

Instantly share code, notes, and snippets.

@patshaughnessy
Created December 23, 2011 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patshaughnessy/1515410 to your computer and use it in GitHub Desktop.
Save patshaughnessy/1515410 to your computer and use it in GitHub Desktop.
def avatar_geometry(style = :original)
@geometry ||= {}
begin
path = avatar.path(style)
unless path
temp_file = Tempfile.open("#{avatar_file_name}_#{style}")
temp_file << avatar.file_contents(style)
path = temp_file.path
end
@geometry[style] ||= Paperclip::Geometry.from_file path
ensure
temp_file.close if temp_file
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment