tengo esta plantilla:Cómo paginar colecciones de 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) }
bruja regresa:
{
"posts": [
{
"post": {
"id": 5,
"title": "...",
"subject": "...",
"user": {
"full_name": "..."
},
"read": true
}
}
]
}
Y me gustaría añadir a añadir algunos parametros de paginación con el fin de prestar este:
{
"posts": [
{
"post": {
"id": 5,
"title": "...",
"subject": "...",
"user": {
"full_name": "..."
},
"read": true
}
}
],
"total": 42,
"total_pages": 12
}
¿Alguna idea? ¡Muchas gracias!
Es mejor agregar información de paginación en la cabecera [ 'Enlace'] gustaría hacer por Github por ejemplo – shingara
estoy totalmente de acuerdo. Sin embargo, en este momento tengo que seguir siendo compatible con algunas API actuales. –