0

我按照https://github.com/stefankroes/ancestry的说明成功安装了祖先 gem ,我的类别表如下所示: 类别(id、category_name、ancestry、created_at、updated_at) 在此处输入图像描述

我想根据 parent->sub-category->sub-sub-category 进行选择: 在此处输入图像描述

此时使用代码(取自https://github.com/stefankroes/ancestry/wiki/Creating-a-selectbox-for-a-form-using-ancestry)我只能设法获得不正确的关注。 在此处输入图像描述

4

1 回答 1

1

Your data is wrong. To model this structure you should have ancestry column properly filled-in. It should contain whole path from the root node (ids of the elements) sepatared by '/'. For example for Watches it should be 5/13 so as it was displayed under Clothes (Id: 13)

于 2014-01-07T08:58:28.750 回答