I am using RABL to generate JSON responses. I am having trouble achieving the following structure:
{
"articles": [
{
"created_at": "2012-10-20T15:57:31Z",
"description": "MK DEsc",
"id": 1,
"title": "MK Title",
"updated_at": "2012-10-20T15:58:14Z",
media:[{
id : 1,
title : "title"
}]
},
{
"created_at": "2012-10-20T16:38:24Z",
"description": "fdsfdffffffff",
"id": 2,
"title": "asdads",
"updated_at": "2012-10-20T16:38:24Z",
media:[{
id : 1,
title : "title"
}]
}
]
}
I have a @artices object which contains media array. i have rabl config setup like:
config.include_json_root = false
config.include_child_root = false
my .rabl template so far looks like this:
object false
node :articles do
@articles.each do |article|
end
end
i am unable to add the media info inside this structure.
any help is appreciated
I have managed to do this like so: