views:

236

answers:

1

With ruby on rails, the scaffolding creates layouts for all the controllers. If I decide to use an application layout, then I need to delete all those layouts (otherwise they will override the application layout). Now, I'm assuming most sites are going to want some site wide menu. The most straightforward place to put a site-wide menu would seem to be the application layout - but then I need to delete all the controller layouts. If I don't use an application layout, then I could use a partial to recreate the menu in all my views. Is there a 'rails' way of doing site wide menus - both options I've considered above seem lacking somehow.

+2  A: 

Yes, the straight forward way to do it is to include your navigation in your application layout. If you need different layouts, I think it's best to include your navigation via a partial. If you are not using the other layouts, get rid of them. Otherwise you have to copy each and every change to the layout multiple times.

In case you only want a subset of your page to display the navigation, you can specify the desired layout in your controller using:

layout "yourLayout"

This railscasts episode gives a nice overview about layouts and how to use them: http://railscasts.com/episodes/7-all-about-layouts

sdfx