app/views/comments/_list.html.erb
<div id="comments">
<% if comments.length == 0 %><p><i>No comments</i></p><% end %>
<div id="comment-list">
<% comments.each do |comment| %>
<div class="comment">
<a name="c<%= comment.id %>"></a>
<div class="header">
<% if logged_in? && (current_user.role == "admin" || current_user.id == comment.user_id) %>
<p class="pull-right"><small><%= link_to '<i class="fa fa-trash"></i>'.html_safe, "/comments/delete/"+comment.id.to_s, :confirm => 'Are you sure?' %></small></p>
<% end %>
<%= time_ago_in_words(comment.created_at) %> ago,
<% if comment.has_user? %><a href="<%= user_path(comment.user) %>"><%= comment.user.login %></a> <a class="anchor" href="#c<%= comment.id %>">wrote</a>:</b>
<% else %><%=h comment.author %> wrote:</b>
<% end %>
</div>
<div class="body">
<%= raw RDiscount.new(comment.body).to_html %>
</div>
</div>
<% end %>
</div>
<div class="comment">
<a name="new-comment"></a>
<div class="header">
<b>Leave a comment</b>
</div>
<div class="body">
<%= render partial: 'comments/form', locals: { datum: datum } %>
</div>
</div>
</div>