# Dynamic content in layouts

**URL:** <https://www.ruby-forum.com/t/dynamic-content-in-layouts/70674>\
**Category:** Rails\
**Created:** [October 1, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-layouts/70674 "2006-10-01T21:19:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoR\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/77aa72/32.png) [@RoR\_newbie](https://www.ruby-forum.com/u/RoR_newbie)\
**Post date:** [October 1, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-layouts/70674/1 "2006-10-01T21:19:09Z")

</div>

My normal dynamic content is added with the yield command, but now I  
would like to add a partial to my layout as well. The partial will  
generate some links depending on which layout is this. It works fine at  
first but when I switch between layouts, all of the links are there. I  
think Rails caches thems. How can I disable this feature? Or work my way  
around it?

---

<div class="post-metadata">

**Author:** ![RoR\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/77aa72/32.png) [@RoR\_newbie](https://www.ruby-forum.com/u/RoR_newbie)\
**Post date:** [October 2, 2006, 9:54am UTC](https://www.ruby-forum.com/t/dynamic-content-in-layouts/70674/2 "2006-10-02T09:54:38Z")

</div>

Upping this. I’d really appreciate some help. 😕

---

<div class="post-metadata">

**Author:** ![RoR\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/77aa72/32.png) [@RoR\_newbie](https://www.ruby-forum.com/u/RoR_newbie)\
**Post date:** [October 2, 2006, 12:28pm UTC](https://www.ruby-forum.com/t/dynamic-content-in-layouts/70674/3 "2006-10-02T12:28:33Z")

</div>

On 10/2/06, RoR newbie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My normal dynamic content is added with the yield command, but now I  
> would like to add a partial to my layout as well. The partial will  
> generate some links depending on which layout is this. It works fine at  
> first but when I switch between layouts, all of the links are there. I  
> think Rails caches thems. How can I disable this feature? Or work my way  
> around it?

I’m not sure that I understand your question, or rather how your having  
this  
issue. Is your partial called from within your layouts? or inside  
another  
view?

There is nothing stopping you from generating a partial in a layout.  
Just  
include the partial in your layout like any other partial

\<%= render :partial =\> ‘my\_partial’ :object =\> some\_object -%\>

This should not be cached unless you have requested that it be cached.

There is specific information regarding caching here

> **[ActionController::Caching](https://api.rubyonrails.org/classes/ActionController/Caching.html)**
>
> Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls around for subsequent requests.

Sorry I couldn’t be more help. Maybe if you could give some more  
information with your specific case…

---

<div class="post-metadata">

**Author:** ![RoR\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/77aa72/32.png) [@RoR\_newbie](https://www.ruby-forum.com/u/RoR_newbie)\
**Post date:** [October 3, 2006, 12:20am UTC](https://www.ruby-forum.com/t/dynamic-content-in-layouts/70674/4 "2006-10-03T00:20:17Z")

</div>

hi  
rails doesn t cache layouts, your problem is likely to be a coding error

also for your case i think it is better to have more than 1 layout (ie  
one  
layout for a specific set of links)

–  
Heri R.  
[http://sprinj.com](http://sprinj.com)
