Module: ToGravatar::HasGravatar

Extended by:
ActiveSupport::Concern
Defined in:
lib/to_gravatar/has_gravatar.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_gravatarObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/to_gravatar/has_gravatar.rb', line 19

def to_gravatar
  gr_id = Digest::MD5.hexdigest(self.read_attribute(self.gr_field).downcase)
  if self.gr_ssl == true
    gravatar_url= "https://secure.gravatar.com/avatar/#{gr_id}.png?s=#{self.gr_size}?r=#{self.gr_rating}"
    gravatar_url += "?d=#{self.gr_default}" if self.gr_default
    return gravatar_url
  else
    gravatar_url = "http://gravatar.com/avatar/#{gr_id}.png?s=#{self.gr_size}?r=#{self.gr_rating}"
    gravatar_url += "?d=#{self.gr_default}" if self.gr_default
    return gravatar_url
  end
end