# Render partial collection locals

**URL:** <https://www.ruby-forum.com/t/render-partial-collection-locals/119582>\
**Category:** Rails\
**Created:** [November 8, 2007, 6:17am UTC](https://www.ruby-forum.com/t/render-partial-collection-locals/119582 "2007-11-08T06:17:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [November 8, 2007, 6:17am UTC](https://www.ruby-forum.com/t/render-partial-collection-locals/119582/1 "2007-11-08T06:17:13Z")

</div>

when i use a partial render with a collection and a hash of locals, i  
don’t get the locals.  
\<%= render :partial =\> ‘/users/user’, :collection =\> @users, :locals  
=\> {:test\_value =\> true} %\>  
isn’t it possible to use both collection and locals with a render?

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [November 8, 2007, 10:39am UTC](https://www.ruby-forum.com/t/render-partial-collection-locals/119582/2 "2007-11-08T10:39:26Z")

</div>

Jean-sÃ©bastien Jney wrote:

> when i use a partial render with a collection and a hash of locals, i  
> don’t get the locals.  
> \<%= render :partial =\> ‘/users/user’, :collection =\> @users, :locals  
> =\> {:test\_value =\> true} %\>  
> isn’t it possible to use both collection and locals with a render?

This works fine for me. When you access the locals, you’re just using  
eg

\<%= test\_value %\>

rather than

\<%= locals[:test\_value] %\>

right?

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [November 8, 2007, 10:40am UTC](https://www.ruby-forum.com/t/render-partial-collection-locals/119582/3 "2007-11-08T10:40:43Z")

</div>

Max W. wrote:

> Jean-sÃ©bastien Jney wrote:
> 
> > when i use a partial render with a collection and a hash of locals, i  
> > don’t get the locals.  
> > \<%= render :partial =\> ‘/users/user’, :collection =\> @users, :locals  
> > =\> {:test\_value =\> true} %\>  
> > isn’t it possible to use both collection and locals with a render?
> 
> This works fine for me. When you access the locals, you’re just using  
> eg
> 
> \<%= test\_value %\>
> 
> rather than
> 
> \<%= locals[:test\_value] %\>
> 
> right?

My mistake, i’m talking out my ass, sorry (not had my morning coffee  
yet)
