wintermute
2007-Apr-19 19:11 UTC
Controller class variables not available to method partials?
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Dylan Markow
2007-Apr-19 23:52 UTC
Re: Controller class variables not available to method parti
<%= render(:partial => "list", :locals => {:list => @list)
%>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---