# Many partials in one view

**URL:** <https://www.ruby-forum.com/t/many-partials-in-one-view/119427>\
**Category:** Rails\
**Created:** [November 6, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/many-partials-in-one-view/119427 "2007-11-06T23:02:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [November 6, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/many-partials-in-one-view/119427/1 "2007-11-06T23:02:48Z")

</div>

Is it possible to render 5 different partials in one view, each of  
which is rendered by an instance variable from a different action? Or  
must all instance variables that render all partials for a given view  
come from the same action?

Charlie

---

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [November 6, 2007, 11:11pm UTC](https://www.ruby-forum.com/t/many-partials-in-one-view/119427/2 "2007-11-06T23:11:35Z")

</div>

On 11/6/07, charlie caroff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is it possible to render 5 different partials in one view, each of  
> which is rendered by an instance variable from a different action? Or  
> must all instance variables that render all partials for a given view  
> come from the same action?
> 
> Charlie

Well there is a component structure that creates a completely new  
request,  
but if you want 5 per one page, then say good bye to any sort of quick  
response time.

Otherwise no, you need to have the variables set by the related  
controller /  
action.

Jason

---

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [November 7, 2007, 3:18pm UTC](https://www.ruby-forum.com/t/many-partials-in-one-view/119427/3 "2007-11-07T15:18:07Z")

</div>

On Nov 6, 2007 5:02 PM, charlie caroff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is it possible to render 5 different partials in one view, each of  
> which is rendered by an instance variable from a different action? Or  
> must all instance variables that render all partials for a given view  
> come from the same action?

Only one action is performed at a time (unless you use components), so  
everything needs to be set from there or in something called from  
there.

But don’t use instance variables in partials:  
[http://www.robertshowalter.com/articles/2007/07/24/dont-use-instance-variables-in-partials](http://www.robertshowalter.com/articles/2007/07/24/dont-use-instance-variables-in-partials)

---

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [November 7, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/many-partials-in-one-view/119427/4 "2007-11-07T18:05:46Z")

</div>

On Nov 6, 2007, at 2:02 PM, charlie caroff wrote:

> Is it possible to render 5 different partials in one view, each of  
> which is rendered by an instance variable from a different action? Or  
> must all instance variables that render all partials for a given view  
> come from the same action?

Like Bob said, don’t use instance vars for partials. Have a look at  
this article for some guidelines on combing views, layouts, and  
partials to achieve modular design and retain OOP objectives.

[http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/](http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/)

– greg willits
