aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-05-27 23:41:50 +1200
committerPhilip Arndt <parndt@gmail.com>2011-05-27 23:41:56 +1200
commitff795b2ab0040b5846960aeed238d9cd749cdad0 (patch)
tree001af6dfa945fd5e019ea277b40000a7015d4271 /app/models
parent92e128d2fbd049c62389598a6c97e6ffd400e2e9 (diff)
downloadrefinerycms-blog-ff795b2ab0040b5846960aeed238d9cd749cdad0.tar.gz
refinerycms-blog-ff795b2ab0040b5846960aeed238d9cd749cdad0.tar.bz2
refinerycms-blog-ff795b2ab0040b5846960aeed238d9cd749cdad0.zip
Added avatar to blog comments based on email address associated with a gravatar.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/blog_comment.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 13aceb1..f461cdb 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -19,6 +19,13 @@ class BlogComment < ActiveRecord::Base
scope :approved, :conditions => {:state => 'approved'}
scope :rejected, :conditions => {:state => 'rejected'}
+ def avatar_url(options = {})
+ options = {:size => 60}
+ require 'digest/md5'
+ options[:size] = "?s=#{size}" if options[:size]
+ "http://gravatar.com/avatar/#{Digest::MD5.hexdigest(self.email.to_s.strip.downcase)}#{size}.jpg"
+ end
+
def approve!
self.update_attribute(:state, 'approved')
end