Как разбивать коллекции Rabl на страницы

У меня есть этот шаблон:

# app/views/posts/index.rabl
collection @posts => :posts
attributes :id, :title, :subject
child(:user) { attributes :full_name }
node(:read) { |post| post.read_by?(@user) }

Witch returns:

{
    "posts": [
        {
            "post": {
                "id": 5,
                "title": "...",
                "subject": "...",
                "user": {
                    "full_name": "..."
                },
                "read": true
            }
        }
    ]
}

И я хотел бы добавить несколько параметров разбивки на страницы, чтобы отобразить это:

{
    "posts": [
        {
            "post": {
                "id": 5,
                "title": "...",
                "subject": "...",
                "user": {
                    "full_name": "..."
                },
                "read": true
            }
        }
    ],
    "total": 42,
    "total_pages": 12
}

Любой идеи? Большое спасибо!

12
задан Zag zag.. 16 February 2012 в 15:08
поделиться