I am trying to design my ruby on rails app at the moment. I created views/layouts/posts.html.erb which styled my 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 views/layouts/application.html.erb
was for.
This seems to agree with me: http://jacqueschirag.wordpress.com/2007/08/02/rails-layout-and-nested-layout-basics/
The entire Rails application (all views of all controllers) will use this layout:
views/layouts/application.rhtml
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:
views/layouts/welcome.rhtml
What am I doing wrong?
Here is what I have in the body of my application.html.erb
<div id="top-bar">
<div id="user_nav">
<% if current_user %>
<%= link_to "My Profile", current_user %>
<%= link_to "Logout", logout_path %>
<% else %>
<%= link_to "Register", new_user_path %>
<%= link_to "Login", login_path %>
<% end %>
</div>
</div>
<%= yield %>