limit to recent comments

This commit is contained in:
Skud committed 2013-02-08 18:14:37 +11:00
1 parent d37e7a148d
commit 8caa4d12e8
4 files changed
+4 -2

No files matched your search

+1
View File
@@ -3,6 +3,7 @@ class CommentsController < ApplicationController
# GET /comments.json
def index
@comments = Comment.all
@recent_comments = Comment.limit(100).order('created_at desc').all
respond_to do |format|
format.html # index.html.erb
+1 -1
View File
@@ -1,6 +1,6 @@
= content_for :title, "Recent comments"
- @comments.reverse.each do |comment|
- @recent_comments.each do |comment|
%h2
Comment on
= link_to comment.post.subject, comment.post
@@ -14,6 +14,7 @@ describe CommentsController do
comment = Comment.create! valid_attributes
get :index, {}
assigns(:comments).should eq([comment])
assigns(:recent_comments).should eq([comment])
end
end
+1 -1
View File
@@ -3,7 +3,7 @@ require 'spec_helper'
describe "comments/index" do
before(:each) do
controller.stub(:current_user) { nil }
assign(:comments, [
assign(:recent_comments, [
FactoryGirl.create(:comment),
FactoryGirl.create(:comment, :body => 'ROFL')
])