在我的项目模型中
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。有什么帮助吗?
答案 0 :(得分:4)
尝试明确传递条件:
@clients = current_user.clients.paginate(
:conditions => {:completed => false},
:page => params[:page], :per_page => 10,
:order => 'started_on DESC')