# Content\_for and view, controller, and default hierarchy

**URL:** <https://www.ruby-forum.com/t/content-for-and-view-controller-and-default-hierarchy/160725>\
**Category:** Rails\
**Created:** [February 19, 2009, 5:49am UTC](https://www.ruby-forum.com/t/content-for-and-view-controller-and-default-hierarchy/160725 "2009-02-19T05:49:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [February 19, 2009, 5:49am UTC](https://www.ruby-forum.com/t/content-for-and-view-controller-and-default-hierarchy/160725/1 "2009-02-19T05:49:43Z")

</div>

I am trying to accomplish a hierarchy for my sidebar content using  
yield :sidebar and content\_for :sidebar. What is the best way to set  
up the content\_for hierarchy such that the following pseudo code is  
true.

if :sidebar code in View  
display View :sidebar  
elsif :sidebar code in Controller  
display Controller :sidebar  
else  
display Default :sidebar

Thanks in advance.
