我试图弄清楚如何列出类别中的产品以获得类似于此的结果:

电话(3)

  • 智能手机(2)

----苹果(1)

---- Android(1)

  • 家用电话(1)

电脑(4)

  • 笔记本电脑(1)

  • 桌面(3)

---- AMD(2)

----英特尔(1)

当我点击某个类别时,它会列出该类别中的产品

我看了:

http://railscasts.com/episodes/162-tree-based-navigation-revised

http://railscasts.com/episodes/262-trees-with-ancestry

并阅读:

http://en.wikipedia.org/wiki/Tree_(data_structure)

http://en.wikipedia.org/wiki/Tree_traversal

http://en.wikipedia.org/wiki/Nested_set_model

但我仍然不明白如何在rails中实现这一点 . 如果有人能指出我正确的方向,我会非常感激 .