Skip to content

Can you confirm Kaminari works well if the Data is fetched from an API through the net (so it is not ActiveRecord or in DB)? #74

Closed
jianlin opened this Issue Apr 2, 2011 · 7 comments

5 participants

@jianlin
jianlin commented Apr 2, 2011

Can you confirm Kaminari works well if the Data is fetched from an API through the net (so it is not ActiveRecord or in DB)?

And how to properly use that with Kaminari?

@leehambley

@jianlin, I'm not the author, but first Kaminari works on the AREL scopes in ActiveRecord… so it's unlikely to work with anything that doesn't conform to the ActiveRecord 3 query syntax, which is inherited from AREL.

Also… this is not a support forum… please take your questions to your local mailing list, or directly to the author, a question about Ruby programming is not a Kaminari issue.

@jianlin
jianlin commented Apr 19, 2011

this is more like a request for documentation. So that it is clear whether Kaminari must work with ActiveRecord or not. Usually, documentation is quite lacking in the gems world, this concern is being filed as an issue.

@amatsuda amatsuda added a commit that referenced this issue Apr 22, 2011
@amatsuda refs #47, #68, #74 generic pagination support for Array object
this enables you to paginate through any Arrayish object in this way:
  Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
e04f65a
@amatsuda
Owner

@jianlin Thanks for the feature request.

Just added an initial implementation of generic Arrayish object support e04f65a.
Can you bundle '>= 0.12.0' gem and try something like this?

Kaminari.paginate_array(your_api_result).page(params[:page])

@jianlin @leehambley
So, I think the problem wasn't actually a documentation issue in this case, but just an "unimplemented feature".
I'm aware of the documentation poorness though, I'm sorry for that. There are still lot more things to do for this young product. As I'm not really a good English document writer (I sometimes hope I can write everything in japanese!), I always welcome your contribution on documentation as well as Ruby code patch.

Anyway, I hope you like the new feature!

@kisp
kisp commented May 12, 2011

I have currently the same use-case of paginating the result of an API call over the net... However, this API
itself is paginated :-) .... (and has lots of records).

Therefore, I cannot use the use the paginate_array method in this case (but it is very useful otherwise...).

I thought that the easiest way to approach this would be to build by own object (some Enumerable, say) and simply make
sure that it responds to #current_page, #num_pages and #limit_value, so that the paginate helper has everything it
needs.

Would you think this is a reasonable approach?

@leehambley

@kisp, this isn't a help forum… but that would be a reasonable implementation (for help questions please see http://www.stackoverflow.com/ )

@amatsuda
Owner

@kisp
Yep. Sounds quite reasonable.
I'm happy to include such kind of wrapper class into Kaminari gem, so could you send me your code when finished implementing?
Thanks!

@zzak
Collaborator
zzak commented Jul 1, 2013

See the wiki for docs

@zzak zzak closed this Jul 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.