I thought views/layouts/application.html.erb was meant to apply to all layouts?

admin

Administrator
Staff member
I am trying to design my ruby on rails app at the moment. I created views/layouts/posts.html.erb which styled my
Code:
PostsController
's views.

I want to add a main bar that is always at the top of the page no matter what view the user is looking at. I thought this was what the
Code:
views/layouts/application.html.erb
was for.

This seems to agree with me:
<a href="http://jacqueschirag.wordpress.com/2007/08/02/rails-layout-and-nested-layout-basics/" rel="nofollow">http://jacqueschirag.wordpress.com/2007/08/02/rails-layout-and-nested-layout-basics/</a>

<blockquote>
<ul>
<li>The entire Rails application (all views of all controllers) will
use this layout:

Code:
views/layouts/application.rhtml
</li>
<li>All views within a single controller will use this layout. For
example, the layout for
weclome_controller.rb will use this
layout. Notice, the ‘_controller’ is
left off for the layout:

Code:
views/layouts/welcome.rhtml
</li>
</ul>
</blockquote>

What am I doing wrong?

Here is what I have in the body of my
Code:
application.html.erb

Code:
  &lt;div id="top-bar"&gt;
      &lt;div id="user_nav"&gt;
        &lt;% if current_user %&gt;
          &lt;%= link_to "My Profile", current_user %&gt;
          &lt;%= link_to "Logout", logout_path %&gt;
        &lt;% else %&gt;
          &lt;%= link_to "Register", new_user_path %&gt;
          &lt;%= link_to "Login", login_path %&gt;
        &lt;% end %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;%= yield %&gt;