jeffmoss / active-resource-pagination

Pagination support for ActiveResource

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

active-resource-pagination Build status

Pagination support for ActiveResource

Usage

class Posts < ActiveResource::Base
  include ActiveResource::Pagination

  ...
end

This will add a JSON decoder that intercepts any response with the format:

{
  "total_pages": 5,
  "current_page": 1,
  "posts": [{
    "id": 1
  }]
}

This should work well with will_paginate style pagination on the controller, typically like this:

posts = Post.all(:params => {:per_page => 5, :page => 1})

About

Pagination support for ActiveResource