Rails check if yield :area is defined in content_for
@content_for_whatever
is deprecated.Use content_for?
instead, like this:
<% if content_for?(:whatever) %> <div><%= yield(:whatever) %></div><% end %>
not really necessary to create a helper method:
<% if @content_for_sidebar %> <div id="sidebar"> <%= yield :sidebar %> </div><% end %>
then of course in your view:
<% content_for :sidebar do %> ...<% end %>
I use this all the time to conditionally go between a one column and two column layout