RABL视图给出错误的输出

时间:2018-07-18 19:39:21

标签: ruby-on-rails rabl

我正在尝试从我的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

我的输出几乎正确,但是paginatorpagination_info属性已添加到每个单独的汽车项目。

任何想法如何获得正确的输出?

0 个答案:

没有答案