我有這樣的模板:如何分頁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) }
女巫返回:
{
"posts": [
{
"post": {
"id": 5,
"title": "...",
"subject": "...",
"user": {
"full_name": "..."
},
"read": true
}
}
]
}
而且我想,爲了補充添加一些分頁PARAMS渲染這樣的:
{
"posts": [
{
"post": {
"id": 5,
"title": "...",
"subject": "...",
"user": {
"full_name": "..."
},
"read": true
}
}
],
"total": 42,
"total_pages": 12
}
任何想法?非常感謝!
最好是添加頁眉分頁信息[「鏈接」]舉例 – shingara 2012-02-16 15:12:18
我完全同意喜歡通過Github上做。但是現在我必須與一些當前的API保持兼容。 – 2012-02-16 16:42:03