# Sidebars should be placed in the main layout or the action's view

**URL:** <https://www.ruby-forum.com/t/sidebars-should-be-placed-in-the-main-layout-or-the-actions-view/194207>\
**Category:** Rails\
**Created:** [September 1, 2010, 3:54am UTC](https://www.ruby-forum.com/t/sidebars-should-be-placed-in-the-main-layout-or-the-actions-view/194207 "2010-09-01T03:54:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zurich\_by\_night](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/d78d45/32.png) [@zurich\_by\_night](https://www.ruby-forum.com/u/zurich_by_night)\
**Post date:** [September 1, 2010, 3:54am UTC](https://www.ruby-forum.com/t/sidebars-should-be-placed-in-the-main-layout-or-the-actions-view/194207/1 "2010-09-01T03:54:15Z")

</div>

Just wondering. Should sidebars be in the view or in the main layout?

If they are in the main layout. i.e. with the following code:

```
  <div class="span-24">

    <div id="content" class="span-18">

        <%= yield %>

    </div>

    <div id="side-panel" class="span-6 last">

        sidebar

    </div>

  </div>

```

If the sidebar has dynamic content (i.e. data being set from the  
action), how can this be displayed? So I am thinking that the sidebar  
must be in the action’s view.

What are your thoughts? What is the rails way of doing this? Or  
perhaps, is there a plugin that one can use?

---

<div class="post-metadata">

**Author:** ![zurich\_by\_night](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/d78d45/32.png) [@zurich\_by\_night](https://www.ruby-forum.com/u/zurich_by_night)\
**Post date:** [September 1, 2010, 4:33am UTC](https://www.ruby-forum.com/t/sidebars-should-be-placed-in-the-main-layout-or-the-actions-view/194207/2 "2010-09-01T04:33:29Z")

</div>

Ok, I found out a better solution. Using \<%= yield :side\_panel %\> in  
main layout and

\<% content\_for :side\_panel do %\>\<%= render :partial =\>  
‘side\_panel\_show’, :object\_topass =\> @object\_topass %\>\<% end %\>

On Sep 1, 9:53 am, Christian F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
