# Local not passing to partial when validation error

**URL:** <https://www.ruby-forum.com/t/local-not-passing-to-partial-when-validation-error/177623>\
**Category:** Rails\
**Created:** [October 21, 2009, 8:04am UTC](https://www.ruby-forum.com/t/local-not-passing-to-partial-when-validation-error/177623 "2009-10-21T08:04:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [October 21, 2009, 8:04am UTC](https://www.ruby-forum.com/t/local-not-passing-to-partial-when-validation-error/177623/1 "2009-10-21T08:04:20Z")

</div>

Hello everyone,

I am passing a variable (showco) to a partial using:

\<%= render(:partial =\> “form”, :object =\> f, :locals=\>{:mode =\> “edit”,  
:showco =\> @showco } ) %\>

It works fine if there are no validation errors. However, when an error  
occurs and the form is redisplayed, the variable is not set. The  
@showco variable is initialized in the controller.

I tried reinitializing the @showco variable in the validation routine in  
the model but still no good.

How can I reinitialize the local variable?

TIA,  
Dan

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [October 23, 2009, 6:50am UTC](https://www.ruby-forum.com/t/local-not-passing-to-partial-when-validation-error/177623/2 "2009-10-23T06:50:43Z")

</div>

Hi Dan S.

```
           Is it solved?If not plese paste your controller code

```

Sijo

---

<div class="post-metadata">

**Author:** ![drsharp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9bcb4/32.png) [@drsharp](https://www.ruby-forum.com/u/drsharp)\
**Post date:** [October 25, 2009, 12:48am UTC](https://www.ruby-forum.com/t/local-not-passing-to-partial-when-validation-error/177623/3 "2009-10-25T00:48:12Z")

</div>

Sijo k g wrote:

> Hi Dan S.
> 
> ```
> Is it solved?If not plese paste your controller code
> 
> ```
> 
> Sijo

Sijo,

I just used a session variable instead.  
Thanks anyway,  
Dan
