I'm trying to return 2 collections in RABL. But I'm having some trouble. What happens is it only returns the second collection when I run it.
Here is the function for the index page the rabl is rendering:
def index
@friends = @currentuser.friends
@pendingfriends = @currentuser.pending_friends
end
In my RABL page I am trying to return both collections like so:
collection @friends, :root => "friends", :object_root => "user"
attributes :id, :username
collection @pendingfriends, :root => "pendingfriends", :object_root => "user"
attributes :id, :username
What happens is it only renders the second collection "pending friends":
{
"pendingfriends": [
{
"user": {
"id": 3,
"username": "ken"
}
}
]
}
If I delete the second collection though the first one appears fine. I'm wondering whats the correct way I can render the 2 collections in my RABL template.
Thanks for any help.