I’ve added
# config/initializers/will_paginate_array_fix.rb
require 'will_paginate/array'
but still do not seem to be getting pagination support for arrays, eg:
def index
@array = (1..100).to_a.paginate(params[:page])
end
# gives TypeError: can't convert Symbol into Integer
It works fine with models, and I get
defined? WillPaginate # => constant
ActiveRecord::Base.respond_to? :paginate # => true
# but:
Array.respond_to? :paginate # => false
Anyone know what I am missing to get pagination support for arrays?
Found the answer by looking at source code in will_paginate/array:
So for arrays, you have to use .paginate (not .page), and you have to pass it as a hash. So the following works: