Mongoid pagination

后端 未结 8 570
無奈伤痛
無奈伤痛 2021-02-05 12:01

I tried

@posts = Post.page(params[:page]).per_page(10)

and

@posts = Post.paginate(:page => 1, :per_page => 10)    
         


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 12:56

    This works fine for me:

    @posts = Post.paginate(:page => 1, :limit => 10).desc(:_id)
    

    desc(:_id) is added so that latest posts could be listed first.

提交回复
热议问题