title: Need advice: Structure of Rails views for submenus?
body: <p>Imagine to have two RESTful controllers (UsersController, OffersController) and a PagesController (used for static content such as index, about and so on) in your application.</p>
  
  <p>You have the following routes defined:</p>
  
  <pre><code>map.with_options :controller =&gt; 'pages' do |pages|
    pages.root :action =&gt; 'index'     # static home page
    pages.about :action =&gt; 'about'    # static about page
    # maybe more static pages...
  end
  map.resources :users    # RESTful UsersController
  map.resources :posts    # RESTful PostsController
  </code></pre>
  
  <p>Your application layout looks like this:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Demo Application&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;ul id="menu"&gt;
         &lt;li&gt;
           &lt;%= link_to 'Home', root_path %&gt;
         &lt;/li&gt;
         &lt;li&gt;
           &lt;%= link_to 'Offers', offers_path %&gt;
           &lt;ul id="submenu&gt;
             &lt;li&gt;&lt;%= link_to 'Search', 'path/to/search' %&gt;&lt;/li&gt;
             &lt;li&gt;maybe more links...&lt;/li&gt;
           &lt;/ul&gt;
         &lt;/li&gt;
         &lt;li&gt;
           &lt;%= link_to 'About', about_path %&gt;
         &lt;/li&gt;
         &lt;li&gt;
           &lt;%= link_to 'Admin', users_path %&gt;
           &lt;ul id="submenu"&gt;
             &lt;li&gt;&lt;%= link_to 'New User', new_user_path %&gt;&lt;/li&gt;
             &lt;li&gt;&lt;%= link_to 'New Offer', new_offer_path %&gt;&lt;/li&gt;
             &lt;li&gt;maybe more links&lt;/li&gt;
           &lt;/ul&gt;
         &lt;/li&gt;
      &lt;/li&gt;
      &lt;%= yield %&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem with the layout is that I want only one <code>#submenu</code> to be visible at any time. All other submenus can be completely skipped (don't need to rendered at all).</p>
  
  <p>Take the Admin menu for example: This menu should be active for all RESTful paths in the application except for <code>offers_path</code>. Active means that the submenu is visible.</p>
  
  <p>The only solution I can think of to achieve this is to build a lot complicated if conditions and that sucks (really complicated to write and to maintain). I'm looking for an elegant solution?</p>
  
  <p>I hope someone understands my question - if there's something unclear just comment the question and I'm going to explain it in more detail.</p>