我正在尝试从我的RABL视图获取此格式的输出:
{
"cars":
[
{
"id":1,
"name":"Car 1",
"garage_name":"This one"
},
{
"id":2,
"name":"Car 2",
"garage_name":"That one"
},
{
"id":3,
"name":"Car 3",
"garage_name":"The other one"
}
],
paginator: "<paginator HTML here>",
pagination_info: "<paginator info HTML here>"
}
我的RABL视图当前为:
collection @cars => :cars
attributes :id, :name, :garage_name
node :paginator do
paginate(@cars, window: 1, outer_window: 2, remote: true)
end
node :pagination_info do
page_entries_info(@cars)
end
我的输出几乎正确,但是paginator
和pagination_info
属性已添加到每个单独的汽车项目。
任何想法如何获得正确的输出?