# Dynamic Layout Positions and Extra Partials

**URL:** <https://www.ruby-forum.com/t/dynamic-layout-positions-and-extra-partials/157484>\
**Category:** Rails\
**Created:** [January 12, 2009, 8:20am UTC](https://www.ruby-forum.com/t/dynamic-layout-positions-and-extra-partials/157484 "2009-01-12T08:20:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sifix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/53a042/32.png) [@sifix](https://www.ruby-forum.com/u/sifix)\
**Post date:** [January 12, 2009, 8:20am UTC](https://www.ruby-forum.com/t/dynamic-layout-positions-and-extra-partials/157484/1 "2009-01-12T08:20:22Z")

</div>

Hallo,  
I am thinking of developing a new project and I would like

1)from the admin areaof the site to control the partials I wan to be  
displayed per page and theirs position.

2)These partials are not always related to the current controller/  
action and needs extra models actions in order to be rendered e.g. a  
user see a car listing page and I want in the sidebar (either left or  
right - according from the settings in the admin area) to render a  
partial let’s say top 10 hot car offers…

I am concerned how could I control the preparation of the partials  
within each controller from a specific action before it could be  
rendered and set the position.

What I am thing is one of the following

1)to use before\_filter create a Model e.g. page and call all the  
necessary actions and database work for all needed partials and this  
model to store these settings in hashes into the page model.  
E.g. {left=\>[partial1 , partial2] , right=\>[partial10]] and finally  
make the @Page model available to the layout

1. to use the embed\_action as described here :  
[http://www.notsostupid.com/blog/2007/10/23/the-embedded-actions-plugin-for-rails/](http://www.notsostupid.com/blog/2007/10/23/the-embedded-actions-plugin-for-rails/)  
but I am concerned if I break the MVC as I will now move back and  
forth from the view and my models

Do you have any better suggestion?  
Thanks for your help…

to be finally available to master layout and set hashes with  
positions

---

<div class="post-metadata">

**Author:** ![sifix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/53a042/32.png) [@sifix](https://www.ruby-forum.com/u/sifix)\
**Post date:** [January 12, 2009, 11:33pm UTC](https://www.ruby-forum.com/t/dynamic-layout-positions-and-extra-partials/157484/2 "2009-01-12T23:33:41Z")

</div>

Anyones Ideas?
