# Ruby on Rails - navigation tree

**URL:** <https://www.ruby-forum.com/t/ruby-on-rails-navigation-tree/171851>\
**Category:** Ruby\
**Created:** [July 10, 2009, 5:51am UTC](https://www.ruby-forum.com/t/ruby-on-rails-navigation-tree/171851 "2009-07-10T05:51:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xenia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/278dde/32.png) [@Xenia](https://www.ruby-forum.com/u/Xenia)\
**Post date:** [July 10, 2009, 5:51am UTC](https://www.ruby-forum.com/t/ruby-on-rails-navigation-tree/171851/1 "2009-07-10T05:51:01Z")

</div>

Hi, folks,

I am trying to build a beautiful navigation tree, to help users browse  
through an inherently hierarchical website. Looking for the  
appropriate control, I chose the yui treeview (javascript). There is a  
site describing how to adjust it to Ruby on Rails  
([http://sonjayatandon.com/07-2006/how-to-get-rails-and-the-yahoo-user-interface-yui-to-talk-part-1/](http://sonjayatandon.com/07-2006/how-to-get-rails-and-the-yahoo-user-interface-yui-to-talk-part-1/)  
etc.).  
I also want to add a custom right-click context menu  
([http://developer.yahoo.com/yui/examples/menu/treeviewcontextmenu.html](http://developer.yahoo.com/yui/examples/menu/treeviewcontextmenu.html)).  
I followed the directions, and they work OK, however, it does not  
escape my attention that I am using Ruby to hardcode javascript. Is  
there another, more elegant, way to do this?

Thanks,  
Xenia , new to Ruby and Rails

---

<div class="post-metadata">

**Author:** ![Xenia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/278dde/32.png) [@Xenia](https://www.ruby-forum.com/u/Xenia)\
**Post date:** [July 10, 2009, 3:31pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-navigation-tree/171851/2 "2009-07-10T15:31:34Z")

</div>

> I also want to add a custom right-click context menu  
> ([http://developer.yahoo.com/yui/examples/menu/treeviewcontextmenu.html](http://developer.yahoo.com/yui/examples/menu/treeviewcontextmenu.html)).  
> I followed the directions, and they work OK, however, it does not  
> escape my attention that I am using Ruby to hardcode javascript. Is  
> there another, more elegant, way to do this?

You could include it as a separate .js file  
[http://www.google.com/search?client=opera&rls=en&q=how+to+include+a+js+file&sourceid=opera&ie=utf-8&oe=utf-8](http://www.google.com/search?client=opera&rls=en&q=how+to+include+a+js+file&sourceid=opera&ie=utf-8&oe=utf-8)

Note also that the rails group might be more helpful since some of us on  
this list don’t use rails as often as they.  
=r
