Skip to content

Instantly share code, notes, and snippets.

@maxim
Created September 26, 2008 15:35
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 maxim/13129 to your computer and use it in GitHub Desktop.
Save maxim/13129 to your computer and use it in GitHub Desktop.
Paperclip::Attachment.interpolations[:hashed_id_3x3] = lambda do |attachment, style|
hash = Digest::MD5.hexdigest(attachment.instance.id.to_s)
hash_path = ''
3.times { hash_path += '/' + hash.slice!(0..2) }
hash_path(1..12)
end
Paperclip::Attachment.interpolations[:hashed_id] = lambda do |attachment, style|
Digest::MD5.hexdigest(attachment.instance.id.to_s)
end
Paperclip::Attachment.interpolations[:kind] = lambda do |attachment, style|
attachment.instance.kind
end
Paperclip::Attachment.interpolations[:format] = lambda do |attachment, style|
attachment.instance.format
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment