# Controller class variables not available to method partials?

**URL:** <https://www.ruby-forum.com/t/controller-class-variables-not-available-to-method-partials/92473>\
**Category:** Rails\
**Created:** [April 19, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/controller-class-variables-not-available-to-method-partials/92473 "2007-04-19T21:12:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [April 19, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/controller-class-variables-not-available-to-method-partials/92473/1 "2007-04-19T21:12:43Z")

</div>

Hi all,

I hope I got the title right. Here is my noob problem. I have one  
controller ‘user’ and a layout for it (also ‘user’). This layout  
displays 3 columns side by side:

- a search box on the left that shows results via view in /user/search  
(through method ‘search’ in controller)
- a display column (through :yield in the controller)
- a shopping list of items with any changes (through a partial in the  
controller)

My problem is in the shopping list. The partial is rendered using:

```
 <%= render(:partial => "list", :object => @list) %>

```

Where @list is a controller class variable. However when I invoke the  
search action I get this error:

```
 NoMethodError in User#search
 Showing app/views/user/_list.rhtml where line #3 raised:

 You have a nil object when you didn't expect it!
 The error occurred while evaluating nil.items

```

So I guess the @list array is unavailable in the search view? Does  
search not inherit from the controller? How can I make it see @list.

Thanks in advance, sorry if this is really easy,

W

---

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [April 20, 2007, 1:52am UTC](https://www.ruby-forum.com/t/controller-class-variables-not-available-to-method-partials/92473/2 "2007-04-20T01:52:17Z")

</div>

\<%= render(:partial =\> “list”, :locals =\> {:list =\> @list) %\>
