Skip to content

Instantly share code, notes, and snippets.

@teeparham
Created April 14, 2011 16:39
Show Gist options
  • Save teeparham/919878 to your computer and use it in GitHub Desktop.
Save teeparham/919878 to your computer and use it in GitHub Desktop.
User with paperclip attachment using proc for default_url
has_attached_file :avatar,
:styles => { :medium => "100x100#", :thumb => "45x45#" }
:default_url => lambda { |a| "/images/avatar_:style_#{a.instance.default_image_number}.png" }
def default_image_number
id.to_s.last
end
# this example allows you to have 10 random default avatars:
# avatar_thumb_0.png, avatar_thumb_1.png, etc.
# avatar_medium_0.png, avatar_medium_0.png, etc.
@pvdb
Copy link

pvdb commented Apr 19, 2011

Come on, thoughtbot, accept the pull request already!!! :-)

@bryanwoods
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment