使用find_all_by_completed(false)时,Paginate排序不起作用

时间:2010-01-22 04:11:13

标签: ruby-on-rails pagination will-paginate

在我的项目模型中

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

由于某种原因,它没有按顺序启动start_on降序。但是,订购适用于另一种方法

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

所以我假设使用find_all_by_completed正在抛弃paginate。我正在使用will-paginate btw。有什么帮助吗?

1 个答案:

答案 0 :(得分:4)

尝试明确传递条件:

@clients = current_user.clients.paginate(
    :conditions => {:completed => false}, 
    :page => params[:page], :per_page => 10, 
    :order => 'started_on DESC')