The Array extensions from will_paginate are for paginating a static array.
  It returns a pagination object.  Here are comments from the file:

  # Example:
  #   arr = ['a', 'b', 'c', 'd', 'e']
  #   paged = arr.paginate(:per_page => 2)      #->  ['a', 'b']
  #   paged.total_entries                       #->  5
  #   arr.paginate(:page => 2, :per_page => 2)  #->  ['c', 'd']
  #   arr.paginate(:page => 3, :per_page => 2)  #->  ['e']

In my situation we are receiving an array which contains part of the total
response, as well as pagination info.  Here is a JSON pseudo-response for
an API request for the first 25 "widgets":

{ "widgets": [widget1, widget2, etc...], "total_widgets":"125",
"total_pages":"5", "page":"1", "per_page":"25" }

Basically, I'm just looking for a library to handle the front-end task of
generating some links.  I know it's not the most difficult task (a simple
view helper method could handle it), but I find myself having to repeat
this process often.



On Fri, Jul 6, 2012 at 10:45 AM, Robert Kaufman <[email protected]> wrote:

> You can bring back the will_paginate Array extensions by requiring
> 'will_paginate/array' in your code.  That gives you the helper methods and
> the view code.
>
> Rob
>
>
>
> On Jul 6, 2012, at 10:32 AM, Benjamin Wanicur wrote:
>
> I'm wondering if there is a Ruby/Rails library out there for generating
> pagination links for a simple Array of Ruby objects.  "Will Paginate" and
> Kaminari (the two most popular pagination libraries ?) require that the
> pagination object include methods like "total_pages" and "current_page".
>  Obviously an Array object does not respond to these methods.  In addition,
> these are full-fledged pagination libraries that handle the back-end, AR
> work.
>
> Here is the situation I have in mind:
> You are making requests against a web service API that supports
> pagination.  You are getting an Array of serialized JSON or XML objects
> back (along with the other necessary pagination info).  You  would like
> some simple pagination links generated with a handy view helper (like the
> "will_paginate" method).
>
> Does anyone know of a gem or library that would handle this situation ?
>
> Cheers
>
> Ben W
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
>
>
>  --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
>

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to