Reputation: 6714
I'm using the rabl gem in my rails API and at the beginning I set config.include_json_root = false
and I've been working without the root of the json response but now I have a new resource and just in that resource I need to get the root.
I was trying something like:
object @myobj, :root => 'foo'
But that's not working at all.
How can I add the json root only to this rabl file and leave everything else without any modification?
Upvotes: 1
Views: 881
Reputation: 6652
Try this:
object false
child(@myobj) {
attribute :attr1 :attr2
}
I was scratching my head for a minute until someone pointed this out to me.
Upvotes: 1
Reputation: 3487
node(:foo) do |myobj|
{
:apy => myobj.apy,
:apr => myobj.apr
}
end
Upvotes: 0