# Controller instance variables not visible in helper method c

**URL:** <https://www.ruby-forum.com/t/controller-instance-variables-not-visible-in-helper-method-c/93201>\
**Category:** Rails\
**Created:** [April 29, 2007, 6:55am UTC](https://www.ruby-forum.com/t/controller-instance-variables-not-visible-in-helper-method-c/93201 "2007-04-29T06:55:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 29, 2007, 6:55am UTC](https://www.ruby-forum.com/t/controller-instance-variables-not-visible-in-helper-method-c/93201/1 "2007-04-29T06:55:18Z")

</div>

I have the following code in an rjs template that I should like to  
move to a helper method associated with the controller:

if @read\_access.value == “MemberEntityAccessibility”  
page.insert\_html :bottom, ‘read\_access\_list’,  
:partial =\> ‘grantee’,  
:collection =\> @read\_grantees  
page.show ‘set\_read\_member\_entities’  
end

I created a helper method called display\_grantees and placed the above  
code within it.

I then called the method from within the existing rjs template using  
page.display\_grantees.

I get an error complaining of a nil object for @read\_access (ie.  
nil.value)

If I leave the code in the rjs template, it works fine. That is, I  
know the instance variables @read\_access etc are being initialised  
correctly.

Thanks.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 29, 2007, 10:55am UTC](https://www.ruby-forum.com/t/controller-instance-variables-not-visible-in-helper-method-c/93201/2 "2007-04-29T10:55:32Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I created a helper method called display\_grantees and placed the above  
> code within it.
> 
> I then called the method from within the existing rjs template using  
> page.display\_grantees.

Try calling the helper as

```
        controller.display_grantees(page)

```

> I get an error complaining of a nil object for @read\_access (ie.  
> nil.value)

–  
We develop, watch us RoR, in numbers too big to ignore.
