I have a Category and Subcategory models in my project. I would like to have many sub-levels in a flexible way. I thought making a self referential "parent" foreign key but I'm not quite sure how to do it. Any ideas? Thanks!
我的项目中有一个Category和Subcategory模型。我想以灵活的方式拥有许多子级别。我认为制作一个自我引用的“父母”外键,但我不太清楚该怎么做。有任何想法吗?谢谢!
Cat1
Sub1
SubSub1
SubSub2
Sub2
Cat2
Sub1
Cat3
Sub1
Sub2
SubSub1
2 个解决方案
#2
5
Awesome_nested_set is the best solution, imo, for these types of structures in rails. http://github.com/collectiveidea/awesome_nested_set
对于轨道中的这些类型的结构,Awesome_nested_set是最好的解决方案imo。 http://github.com/collectiveidea/awesome_nested_set
#1
#2
5
Awesome_nested_set is the best solution, imo, for these types of structures in rails. http://github.com/collectiveidea/awesome_nested_set
对于轨道中的这些类型的结构,Awesome_nested_set是最好的解决方案imo。 http://github.com/collectiveidea/awesome_nested_set