#162 Tree-Based Navigation (revised)
Dec 01, 2012 | 10 minutes | Active Record, Views, Plugins
If your Rails app is content-heavy, consider organizing it in a tree menu structure. Here I show how to add top-level tabs, nested links in a side bar, and breadcrumbs to go up the hierarchy.
- source codeProject Files in Zip (42.6 KB)
- mp4Full Size H.264 Video (18.5 MB)
- m4vSmaller H.264 Video (10.5 MB)
- webmFull Size VP8 Video (14.1 MB)
- ogvFull Size Theora Video (22 MB)
Could you post the CSS for the menus? Or add to show notes?
It's in the GitHub repo:
Is this true? Is there a way to cache a fragment in the context of the currently viewing page?
Or you can use pure CSS to highlight current page based on nested classes.
E.g, body.products > nav.item
Highlight nav.item.products when the body is also products.
I would also recommend the mongoid-ancestry gem for Mongoid based Rails apps.
simple_formatmight be new... then I found that it was added 8 years ago :P
Thanks for this episode.
Is there a technical reason for chosing the "Ancestry" gem rather than the "Awesome nested set" gem ? The second one seems to be more popular for few months no ?
I'm afraid that, if I start building my app with Ancestry, it could be deprecated in few weeks. :/
Yes, you could do something like this:
And then open the submenu with, let's say jQuery:
Thank you very much John! that really works.
Thanks, really helpful!
I'm having difficulty finding out how to go about ordering the sub-tree navigation alphabetically?
I see, it's all in the arrange!
I had a very similar problem. Thank you for posting a solution, this does not happen often on the internet :)
The source code for this episode has been updated to Rails 4.2.6. You can download it from cms4