Created
April 14, 2011 16:39
-
-
Save teeparham/919878 to your computer and use it in GitHub Desktop.
User with paperclip attachment using proc for default_url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Come on, thoughtbot, accept the pull request already!!! :-)