我如何在rails 3.2中将元数据添加到json响应? 有没有办法访问模型元数据并包括?即。字段名称和数据类型。
如下所示:
{
"metaData":{
"columns":[
{
"dataIndex":"id",
"text":"User ID",
"type":"integer"
},
{
"dataIndex":"name",
"text":"User Name",
"type":"string"
},
{
"dataIndex":"birthday",
"format":"dd-mmm-yy",
"text":"Birthday",
"type":"datetime"
}
]
},
"data":[
{
"id":1,
"name":"Queen Elizabeth",
"birthday":"1533-09-07T06:33:39Z"
},
{
"id":2,
"name":"Queen Elizabeth II",
"birthday":"1926-04-21T02:40:00Z"
}
]
}