aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/blog_comment.rb7
-rw-r--r--app/views/blog/posts/_comment.html.erb1
2 files changed, 8 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
diff --git a/app/views/blog/posts/_comment.html.erb b/app/views/blog/posts/_comment.html.erb
index ba4a508..17b2002 100644
--- a/app/views/blog/posts/_comment.html.erb
+++ b/app/views/blog/posts/_comment.html.erb
@@ -1,4 +1,5 @@
<article class='blog_comment_message' id='<%= "comment-#{comment.to_param}" %>'>
+ <%= image_tag comment.avatar_url, :alt => comment.name, :class => 'avatar' %>
<%= simple_format auto_link(comment.message.to_s) %>
<footer class='blog_comment_author'>
<p>