Pagination on arrays


#1

I’m looking for a way to paginate an array of data basically. I know
about will_paginate but from what I’ve seen that only works on
activerecord searches. I can’t seem to find a good resource that lets
you paginate a regular data set. Anyone got a tip on this? I’d really
appreciate it :slight_smile:


#2

will_paginate does work on arrays. You need to create an instance of
WillPaginate::Collection targetting your array. I think there’s an
example in the dogs

Sent from my iPhone

On 11 Dec 2008, at 17:25, Mark Mr removed_email_address@domain.invalid


#3

I think there’s an example in the dogs

Sent from my iPhone

LOVE that iPhone spell checker


#4

lol well his spell-checked wouldn’t have picked up “dogs” obviously. I
couldn’t find an example in the help docs but I figured out how to do
it, which was actually really easy.

@x.paginate(:per_page => 10)

:smiley: