Commit b00345a

mo khan <mo@mokhan.ca>
2013-06-22 17:08:00
add gravatar image
1 parent 1909135
Changed files (2)
app/helpers/application_helper.rb
@@ -1,2 +1,6 @@
 module ApplicationHelper
+  def gravatar_for(user, options = { size: 80 })
+    gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
+    image_tag("https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{options[:size]}&d=mm", alt: user.email, class: 'gravatar')
+  end
 end
app/views/needs/index.html.erb
@@ -25,11 +25,13 @@
     <h1>Needs</h1>
     <table class="table">
       <tr>
+        <th>Person</th>
         <th>Description</th>
         <th></th>
       </tr>
       <% @needs.each do |need| %>
         <tr>
+        <td><%= gravatar_for(need.user) %></td>
         <td><%= need.description %></td>
         <td><%= link_to "I can help...", need_path(need), :class => "btn" %></td>
       </tr>