# Render :partial stops setting local variables

**URL:** <https://www.ruby-forum.com/t/render-partial-stops-setting-local-variables/89103>\
**Category:** Rails\
**Created:** [January 3, 2006, 10:31pm UTC](https://www.ruby-forum.com/t/render-partial-stops-setting-local-variables/89103 "2006-01-03T22:31:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanwarburton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@seanwarburton](https://www.ruby-forum.com/u/seanwarburton)\
**Post date:** [January 3, 2006, 10:31pm UTC](https://www.ruby-forum.com/t/render-partial-stops-setting-local-variables/89103/1 "2006-01-03T22:31:54Z")

</div>

I’m not sure what happened, or what change has caused this to happen,  
but  
render :partial (or any render for that matter, doesn’t seem to let me  
set  
local variables via the local\_assigns argument hash.

for example

\<%= render :partial ‘edit’, :username =\> @user.username %\>

used to allow that username was a local variable in my \_edit.rhtml  
partial  
template.  
example:

**Username:** \<%= username %\>

Could this be a problem with Ruby 1.8.4?

–  
Sean W.  
master nerd of  
i heart squares, Co.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613  
Ph. (773) 531-6301 Fx. (773) 529-7041  
[http://www.iheartsquares.com](http://www.iheartsquares.com)

---

<div class="post-metadata">

**Author:** ![seanwarburton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@seanwarburton](https://www.ruby-forum.com/u/seanwarburton)\
**Post date:** [January 3, 2006, 10:53pm UTC](https://www.ruby-forum.com/t/render-partial-stops-setting-local-variables/89103/2 "2006-01-03T22:53:43Z")

</div>

On 1/3/06, Sean W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Could this be a problem with Ruby 1.8.4?

Tried it on Ruby 1.8.2 and it still fails… Is there soem sort of  
environment setting that controls how varaibles get passed in the render  
method? This used to work fine, yestrday, but suddenly today, on all my  
machines this stopped working.

Any help or insight would be greatly appreciated.

–  
Sean W.  
master nerd of  
i heart squares, Co.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613  
Ph. (773) 531-6301 Fx. (773) 529-7041  
[http://www.iheartsquares.com](http://www.iheartsquares.com)

---

<div class="post-metadata">

**Author:** ![seanwarburton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@seanwarburton](https://www.ruby-forum.com/u/seanwarburton)\
**Post date:** [January 3, 2006, 10:56pm UTC](https://www.ruby-forum.com/t/render-partial-stops-setting-local-variables/89103/3 "2006-01-03T22:56:50Z")

</div>

On 1/3/06, Sean W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m not sure what happened, or what change has caused this to happen, but  
> render :partial (or any render for that matter, doesn’t seem to let me set  
> local variables via the local\_assigns argument hash.
> 
> for example
> 
> \<%= render :partial ‘edit’, :username =\> @user.username %\>

I believe you want:

\<%= render :partial ‘edit’, :locals =\> {:username =\> @user.username} %\>

---

<div class="post-metadata">

**Author:** ![seanwarburton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@seanwarburton](https://www.ruby-forum.com/u/seanwarburton)\
**Post date:** [January 4, 2006, 8:06pm UTC](https://www.ruby-forum.com/t/render-partial-stops-setting-local-variables/89103/4 "2006-01-04T20:06:25Z")

</div>

On 1/3/06, Lance B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I believe you want:
> 
> \<%= render :partial ‘edit’, :locals =\> {:username =\> @user.username} %\>

Ahhh thanks… Thats it!

I take it that [api.rubyonrails.com](http://api.rubyonrails.com) isn’t up to date.  
[Peak Obsession](http://api.rubyonrails.com/classes/ActionView/Base.html#M000468)  
show this still  
_render_(options = {}, old\_local\_assigns = {})

I also tried the previous way containing the two hash arguments in curly  
braces, it still ignored the local assigns.

I just wonder why this was working fine before, and then suddenly  
stopped  
working?

–  
Sean W.  
master nerd of  
i heart squares, Co.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613  
Ph. (773) 531-6301 Fx. (773) 529-7041  
[http://www.iheartsquares.com](http://www.iheartsquares.com)
