Ruby on Rails - 很棒的嵌套集插件 [英] Ruby on Rails - Awesome nested set plugin
问题描述
在使用这个插件时,有没有一种简单的方法可以显示整个嵌套集?我想要做的是显示一个根节点的无序列表,每个子节点中还有另一个无序列表,其中还包含子节点等等?
Is there a simple way to display the entire nested set when using this plugin? What I would like to do is display an unordered list of root nodes with another unordered list inside each child that also contains children and so on?
感谢任何建议.
谢谢.
推荐答案
使用 your_model.children 将需要在每次遇到数据库时再次命中,这是不可取的.
Using your_model.children will require another hit on the database each time it is encountered which is not preferable.
我创建了一个帮助器,它帮助生成嵌套的 ul 和 li 标签,并且只有一个数据库命中.您可以根据自己的需要修改此帮助程序:
I have created a helper which helps generate the nested ul and li tags with only one database hit. You can modify this helper for your own needs:
这篇关于Ruby on Rails - 很棒的嵌套集插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!