I have a partial called _main_nav.html.erb in views/layout folder, this is content file:
<% content_for :main_navigation do %>
<h1>Something must here</h1>
<% end %>
In my _header.html.erb file, i used yield to insert content:
...
<%= yield :main_navigation %>
<nav id="utility" class="nav-collapse">
...
But when i visit home page, it does’n appear h1 element, i have wrong somewhere?
The issue is that you are trying to yield content from a view that isn’t currently being rendered.
You would need to do:
_header.html.erb
_main_nav.html.erb
http://guides.rubyonrails.org/layouts_and_rendering.html#understanding-yield