开发者

Self-referential association in Rails 2.3

I have model called test, and test can have many te开发者_开发技巧sts, and should be able to have a reference to it's parent test if it exists. EG

  • test <-- parent doesn't exist

    • test

      • test

      • test

        • test

      • test

    • test

  • test <-- parent doesn't exist

i've seen a couple of possible solutions with examples before 2.3, but how models handle references seems to have changed a lot since 2.0. I was wondering if anyone has a best route option for doing this with some 2.3 spiffiness. Any suggestions?


If each test can have one parent and many children, this seems like an ideal use for acts_as_tree or acts_as_nested_set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜