title: Ruby on Rails - Layout and Links
body: <p>new to Ruby so I'm still getting to grips with some of the Rails framework and how it relates. I've got a question about why my project behaves in a certain way. </p>
  
  <p>I've created a basic layout, header the top of screen, side menu on the left, and a contents page for the main area. Nothing flash, bog standard as you can see from the code below. (Note, for whatever reason my code below doesn't want to get printed correctly on this page!!)</p>
  
  <hr>
  
  <pre><code>-&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  &lt;% content_for :head do%&gt;
   &lt;% auto_discovery_link_tag %&gt;
  &lt;% end %&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
   &lt;head&gt;
    &lt;title&gt;MyLife&lt;/title&gt;
    &lt;%= stylesheet_link_tag 'main'%&gt;
    &lt;%= javascript_include_tag :defaults %&gt;
    &lt;%= yield :head %&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;div id="container"&gt;
     &lt;div id="header"&gt;
      &lt;%=image_tag 'mylife.jpg', :alt =&gt; "MyLife" %&gt;
     &lt;/div&gt;
     &lt;div id="sidemenu"&gt;
      &lt;%= render :partial =&gt; 'layouts/menu'%&gt;
     &lt;/div&gt;
     &lt;div id="content"&gt;
      &lt;% if flash[:notice] -%&gt;
       &lt;div id="notice"&gt;&lt;%= flash[:notice]%&gt;&lt;/div&gt;
      &lt;% end -%&gt;
      &lt;% if flash[:error] -%&gt;
       &lt;div id="error"&gt;&lt;%= flash[:error]%&gt;&lt;/div&gt;
      &lt;% end -%&gt;
      &lt;%= yield %&gt;
     &lt;/div&gt; 
    &lt;/div&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>For the side bar, I've just got some links to a few pages that I want displayed in the contents area - again nothing flash as you can see below. </p>
  
  <hr>
  
  <pre><code>&lt;ul&gt;
   &lt;!-- These links are standard for everyone - links to the Homepage, and to the Articles news page --&gt;
   &lt;li&gt;&lt;%= link_to 'Home', index_url %&gt;&lt;/li&gt;
   &lt;li&gt;&lt;%= link_to 'News', articles_path %&gt;&lt;/li&gt;
  
   &lt;hr size = "1" width = "90%" aligh = "left" /&gt;
  
   &lt;!-- The remaining links will change depending on context, login state &amp; credentials--&gt;
   &lt;% if is_logged_in? %&gt;
    &lt;li&gt; Logged in as: &lt;i&gt;&lt;%= logged_in_user.username %&gt; &lt;/i&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'My Profile', edit_user_path(logged_in_user) %&gt; &lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Articles', articles_path %&gt; &lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Logout',{:controller =&gt; 'account', :action =&gt; 'logout'}, :method =&gt; :post  %&gt; &lt;/li&gt;
   &lt;% else %&gt;
    &lt;li&gt;&lt;%= link_to 'Signup', :controller =&gt; 'users', :action =&gt; 'new' %&gt; &lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Login', :controller =&gt; 'account', :action =&gt; 'login' %&gt;&lt;/li&gt;
   &lt;% end %&gt;
  
   &lt;% if logged_in_user and logged_in_user.has_role?('administrator') %&gt;
    &lt;hr size="1" width="90%" align="left"&gt;
    &lt;li&gt;&lt;b&gt;Admin Options&lt;/b&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Administer Users', users_path %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Edit Page', pages_path%&gt;&lt;/li&gt;
   &lt;% end %&gt;
  
   &lt;% if is_logged_in? and logged_in_user.has_role?('editor') %&gt;
    &lt;hr size="1" width="90%" align="left"&gt;
    &lt;li&gt;&lt;b&gt;Editor Options&lt;/b&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Edit News Articles', admin_articles_path%&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to 'Edit News Categories', admin_categories_path%&gt;&lt;/li&gt;
   &lt;% end %&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <hr>
  
  <p>My frustration (at being new to the Rails framework) is that when I click on anything Article related (News link, Articles link), the formatting of my page goes and that rendered page gets displayed without the side menu, or the header. All other links behave as expected, with the linked-to page displaying within the Contents pane. What's going on here? </p>
  
  <p>I'm sure I"m missing something very silly, and I can't seem what - which is damn frustrating! </p>
  
  <p>Thanks in advance for helping a newb...</p>