Mongoid pagination

后端 未结 8 656
無奈伤痛
無奈伤痛 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条回答
  •  萌比男神i
    2021-02-05 12:56

    A bit late, but for anyone else looking, I found 'will_paginate_mongoid'

    https://github.com/lucasas/will_paginate_mongoid

    Really straight forward and lets you simply do

    collection.skip(20).limit(10)
    

提交回复
热议问题