Pergunta

What's the best way to implement pagination in a REST API so that an ActiveResource client can easily navigate paginated results? There have been some proposals, for example here and here, but being new to ActiveResource I'm wondering if there's a better way.

Foi útil?

Solução

I did it with kaminari and some patch to activeresource, here is gem with example https://github.com/Fivell/activeresource-response

Outras dicas

I haven't had a chance to dig into this for a project yet, but this fork of Will_Paginate may be of use to you. It adds support for the paginate method to ActiveResource.

We've released a gem built by us based on stuff in production in a pretty high traffic Rails app. It enables pagination transparently by adding current_page, per_page and total_entries as attributes to the root node of the serialied collection XML (and is very fast if you use LibXML or Nokogiri, which I'd strongly recommend over the default of REXML).

Here's the link to the GitHub project for PoxPaginate.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top