Paginating an Array in Ruby with will_paginate

前端 未结 5 1571
耶瑟儿~
耶瑟儿~ 2020-11-27 16:56

I have an array @level1 which looks like this :

[[3.0, 4, 2], [2.0, 48, 3], [2.1, 56, 4], ............]

I want to apply pagination on this

5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 17:17

    Given a collection array in a Rails project

    will_paginate ~>3.0.5
    
    collection.paginate(page: params[:page], per_page: 10)
    

    returns the pagination for the array values.

    Do not forget require 'will_paginate/array' on top of the controller.

提交回复
热议问题