Reputation: 994
I'm having a bit of trouble with rabl
. This code
collection favourite_groups, root: :groups
extends 'favourites/base'
gives me the following json structure: { groups: [ {..}, {..} ] }
. What I need is to append another node that contains an array - { groups: [ {..}, {..} ], users: [ {..}, {..} ] }
The data is in separate variables, but it can be in one, which ever makes this work.
Ideas?
Upvotes: 1
Views: 2767
Reputation: 1
Maybe it's too late for an anwser I did try you syntax but didn't work for me : I think if you append a child with no record, this will confuse rabl engine, because it's looking for a descendent of the root object I did replace with a node element and a partial and it works
object false # ok, no record
node :favourite_groups => :groups do
partial('favourites.json.rabl', :object => @favourite_groups)
end
node :favourite_users => :users do
partial('favourites.json.rabl', :object => @favourite_users)
end
There is an explanation what are the differences between node and child Github rabl Tips and tricks
Hope this help
Upvotes: 0
Reputation: 994
Ok, nevermind, made it work with this
object false
child favourite_groups => :groups do
collection favourite_groups
extends 'favourites/base'
end
child favourite_users => :users do
collection favourite_users
extends 'favourites/base'
end
Upvotes: 9