I'm having some problems creating a tree menu using Rails 3.1 and Mongoid. I have a site model that embeds_many pages. Pages can have a parent page using a field called parent
.
I want to list all existing pages in an unordered list and sub pages should a开发者_如何转开发ppear in a list under the parent, obviously.
I'm fairly new to both Rails and NoSQL but hey, we all are in the beginning. Anyone have a simple solution for this?
mongoid supports recursive embedding / tree structures. see here http://mongoid.org/docs/relations/embedded/1-n.html, scroll down to "RECURSIVE EMBEDDING / CYCLIC RELATIONS" works fine, even if the root node is itself embedded in another document.
精彩评论