rosa-build/app/helpers/users_helper.rb

22 lines
575 B
Ruby
Raw Permalink Normal View History

module UsersHelper
2012-03-11 17:06:41 +00:00
def avatar_url_by_email(email, size = :small)
2014-01-21 04:51:49 +00:00
avatar_url(User.where(email: email).first || User.new(email: email), size)
2012-03-11 17:06:41 +00:00
end
def avatar_url(subject, size = :small)
if subject.try('avatar?')
subject.avatar.url(size)
elsif subject.kind_of? Group
'ava-big.png'
else
2013-04-02 16:14:32 +01:00
gravatar_url(subject.email, User::AVATAR_SIZES[size])
end
end
def gravatar_url(email, size = 30)
2015-03-24 11:47:59 +00:00
hex = email.present? ? Digest::MD5.hexdigest(email.try :downcase) : ''
"https://secure.gravatar.com/avatar/#{}?s=#{size}&r=pg"
end
end