Skip to content

Instantly share code, notes, and snippets.

@victorbstan
Created June 14, 2013 02:49
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 victorbstan/5779141 to your computer and use it in GitHub Desktop.
Save victorbstan/5779141 to your computer and use it in GitHub Desktop.
A module for defaulting to a gravatar image when your profile's own paperclip image isn't available.
require 'digest/md5'
module ProfilePhoto
def profile_photo(profile)
profile.avatar.url(:thumb).present? ? profile.avatar.url(:thumb) : "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(profile.owner.email)}?d=mm"
end
end
# in your application_helper use:
# module ApplicationHelper
# include ProfilePhoto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment