views:

433

answers:

2

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.

A: 

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.

ry
A: 

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.

Kai Wren
Incidentally, Rails' serialisation implementation isn't very RESTful at all, so if you're worrying about hypermedia etc. - don't. ActiveResource is a turd and doesn't support *any* of that.
Kai Wren