0

My application retrieves items from remote source something like that:

# in the controller
@items = RemoteSource(params[:page]) 

The @items is an array but just the part of whole collection. And I'm trying to paginate it:

# in the view
paginate @items

Of course it doesn't work.

How I can paginate my collection in such situation?

P.S. I'm using gem kaminari

megas
  • 21,401
  • 12
  • 79
  • 130
  • Search first http://stackoverflow.com/questions/2529684/rails-paginate-existing-array-of-activerecord-results , http://stackoverflow.com/questions/4352895/ruby-on-rails-will-paginate-an-array , http://stackoverflow.com/questions/6545990/rails-3-kaminari-pagination-for-an-simple-array (surely one or more contains the answers you are looking for, and links the the documentation/API) – user2246674 May 19 '13 at 19:29
  • Is `@items` an array? You can use the helper `paginate_array`. – Pigueiras May 19 '13 at 19:39

1 Answers1

0

Try the Kaminari helper for this: @books = Kaminari.paginate_array(@items).page(params[:page])

jameswilliamiii
  • 868
  • 6
  • 12