@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