我的 Rails 3.2 应用程序中有以下 RABL 文件:
collection @results.limit(5)
attributes :date, :client_id
child :client do
attributes :Surname
end
child :animal do
attributes :AnimalName
end
我想添加结果所属的用户名。我在 RABL 文档中阅读的所有内容似乎都表明只有child
并且node
可用。
我怎样才能在上面的代码中获得父母属性?显然,只要执行以下操作就会返回 NULL!
child :animal do
attributes :AnimalName
end
这可能吗?
当前 JSON 输出:
{
date: "2013-06-25T19:36:11+01:00",
client_id: 88172,
client: {
Surname: "Strange"
},
animal: {
AnimalName: "Ria"
}
},
期望的输出:
{
date: "2013-06-25T19:36:11+01:00",
client_id: 882372,
client: {
Surname: "Summer"
},
animal: {
AnimalName: "Ria"
},
user: {
UserName: "Danny"
}
},