@comments
现在有10条记录排序id ASC
。
我想简单的反序,所以我编写@comments = @comments.reverse
如何排序按日期时间排序的记录?
但我得到这个错误信息
ActionView::Template::Error (undefined method `total_count'
<%= page_entries_info(@comments, :entry_name => 'comment').html_safe %>
如果我脱下反向并把它作为@comments = @comments
,不会有任何问题。 为什么?我怎样才能按created_at DESC
排序呢?
@comments = Comment.where(:user_id => user_ids, :commentable_type => commentable)
if params[:page].blank?
params[:page] = ((@comments.count - 1)/10) + 1
@comments = @comments.page(params[:page]).per(10)
else
@comments = @comments.page(params[:page]).per(10)
end
@comments = @comments.reverse
这不是我不想要:(如果我这样做,第一页都将有最新帖子 – MKK
你问我如何排序顺序由created_at desc。修改问题。你想要什么?最新的帖子按时间顺序排列或按id字段排列的最新帖子? – cpjolicoeur
我希望它们在'同一'顺序但'DESC'顺序在同一页内。 – MKK