4

在我的项目模型中

  def incomplete
  @clients = current_user.clients.find_all_by_completed(false).paginate
  (:page => params[:page], :per_page => 10, :order => 'started_on DESC')
  end

出于某种原因,它不会按started_on 降序排列。然而,订购以另一种方法工作

def all
@clients = current_user.clients.paginate(:page => params[:page], :per_page => 25, :order => 'started_on DESC')
end

所以我假设使用 find_all_by_completed 会引发分页。我正在使用将分页顺便说一句。有什么帮助吗?

4

1 回答 1

4

尝试显式传递条件:

@clients = current_user.clients.paginate(
    :conditions => {:completed => false}, 
    :page => params[:page], :per_page => 10, 
    :order => 'started_on DESC')
于 2010-01-22T05:29:04.410 回答