I have a simple array of hashes retrieved from Redis in my Ruby on Rails application. These are a list of items that I’d like to paginate in a view. They are not ActiveRecord based or based on any database ORM wrapper. They’re simply retrieved like this:
@items = $redis.lrange("items-#{params[:id]}", 0, -1)
At this point I want to do something as simple as list 10 items per page and allow the user to paginate through them.
Is there a plugin/tool available that works on straight arrays? It seems most stuff is focused on ActiveRecord.
If you use the Kaminari gem, you can add pagination to an array.
Then in your view it’s as simple as