Twitter Updates

Saturday, 3 October 2009

Rails Menus using Partials

I have struggled to find a good tutorial on this, probably would not need it if I knew Rails better though. I would like to make a menu which is used through out my Ruby on Rails site, partials seem to be the correct thing to use.

create a new folder 'shared'
and create a new file called _menu.rhtml.

which contains the menu something like (sorry for the extra spaces only way I could stop it rendering):
< id="menu">
< class="menubar">
< class="menubar">< href="">Home< / a>< / l i>
< class="menubar">< href="">Posts< / a>< /l i >
< class="menubar">< href="">Tags< / a>< / l i>
< / u l>
< / d i v>
Then add <%= render(:partial => "shared/menu") %> to all default layouts. in:

No comments: