我正在使用 Rails 中的祖先 gem 来嵌套一些注释,我想要的是让您能够获取所有注释,然后将它们全部嵌套。当我输入时,我如何得到以下信息:@comments = post.comments.arrange_serializable
进入我的评论控制器索引操作并得到以下结果:
{
"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":[
]
}
]
}
很明显,评论id: 5
假设在数组中children
位于评论中id: 4
which IS嵌套在注释下id: 3
.
有人可以告诉我为什么吗arrange_serializable
没有“多巢”评论吗?或者是否有其他函数可以执行此操作。