make /comments show latest comments

This commit is contained in:
joshua stein 2012-07-20 17:54:09 -05:00
parent c34abddc3d
commit 0c0aa465bb
2 changed files with 27 additions and 0 deletions

View file

@ -169,6 +169,26 @@ class CommentsController < ApplicationController
render :text => "ok"
end
def index
@title = "Newest Comments"
@cur_url = "/comments"
@comments = Comment.find(:all, :conditions => "is_deleted = 0 AND " +
"is_moderated = 0", :order => "created_at DESC", :limit => 20,
:include => [ :user, :story ])
if @user
@votes = Vote.comment_votes_by_user_for_story_hash(@user.id,
@comments.map{|c| c.story_id }.uniq)
@comments.each do |c|
if @votes[c.id]
c.current_vote = @votes[c.id]
end
end
end
end
def threads
@title = "Your Threads"
@cur_url = "/threads"

View file

@ -0,0 +1,7 @@
<% @comments.each do |comment| %>
<ol class="comments comments1">
<%= render :partial => "comments/comment", :locals => { :story =>
comment.story, :comment => comment,
:show_story => true } %>
</ol>
<% end %>