Question

How do I create a child which has a RABL collection inside it?

JSON needed : collection @listings should be a child of result.

{
    result: {
        listings: [
            {
                id: 1,

            },
            {
                id: 2,

            }
        ]
    }
}

RABL template with a child having collection:

object false

child @result => :result do
  collection @rents , :root => "listings", :object_root => false  

  attributes :id

end

But I get output as with the above template :

{
    result: [
        {
            id: 1
        },
        {
            id: 2
        }
    ]
}
Was it helpful?

Solution

I have never used RABL, but can`t you do something like this?:

object false

child @result => :result do
  child :listings
    collection @rents , :root => "listings", :object_root => false  
  end
  attributes :id

end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top