Hello All,
I am new to ruby programming,
Problem is -
In my controller -
I defined a private method like
:private
def _list(searchBy, moreResults = false)
# another code goes here.................
@items_by_language = {}
@items.each do |item|
@items_by_language[item.language]=[] if
@items_by_language[item.language] == nil
@items_by_language[item.language] << item
end
end
# This @items_by_language is a hash which I am accessing in my view
named list.html.erb But I get following error
NoMethodError in Home#list
Showing home/list.html.erb where line #6 raised:
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #6):
list.html.erb code -----------------------
<%@items_by_language.each do |key,val|%>
<%val.each do |items|%>
//////code performed on @items_by_language hash variable
<%end%>
<%end%>
------------------------------------------------------------------------
In controller "_list method" is private and I want it private . Thats
why it is not allowed me to access @items_by_language.
What should I do?
Thanks,
Vikas
--
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
-~----------~----~----~----~------~----~------~--~---