Ruby on Rails will_paginate an array

will_paginate 3.0 is designed to take advantage of the new ActiveRecord::Relation in Rails 3, so it defines paginate only on relations by default. It can still work with an array, but you have to tell rails to require that part.

In a file in your config/initializers (I used will_paginate_array_fix.rb), add this

require 'will_paginate/array'

Then you can use on arrays

my_array.paginate(:page => x, :per_page => y)

Leave a Comment