I am using the ancestry gem in rails to nest some comments, and what I wanted was for you to be able to get all comments and then have them all nested. How ever I get the following when I put: @comments = post.comments.arrange_serializable
into my comments controller index action and get the following result:
{
"comments":[
{
"id":3,
"comment":"284723nbrkdgfiy2r84ygwbdjhfg8426trgfewuhjf",
"author":"asdasdasdas",
"post_id":268,
"ancestry":null,
"created_at":"2014-06-17T19:23:04.667Z",
"updated_at":"2014-06-17T19:23:04.667Z",
"children":[
{
"id":4,
"comment":"284723nbrkdgfiy2r84ygwbdjhfg8426trgfewuhjf",
"author":"asdasdasdas",
"post_id":268,
"ancestry":"3",
"created_at":"2014-06-17T19:24:02.408Z",
"updated_at":"2014-06-17T19:24:02.408Z",
"children":[
]
}
]
},
{
"id":5,
"comment":"97ryhewfkhbdasifyt834rygewbfj,dhsg834",
"author":"asdasdasd",
"post_id":268,
"ancestry":"4",
"created_at":"2014-06-17T20:30:04.887Z",
"updated_at":"2014-06-17T20:38:16.060Z",
"children":[
]
}
]
}
It's very apparent that comment with id: 5
is suppose to be in the array of children
which sits in comment id: 4
which IS nested under comment with id: 3
.
Can some one one tell me why arrange_serializable
does not "multi nest" comments? or if there is another function to do this with.