From: Sven Schott Date: 2004-11-29T10:01:42+09:00 Subject: Rails list method I have setup rails and it works nicely. I have used the scaffolding to get started(brilliant) but when I get to replacing the list method, I get an error. I have gone through the tutorials thoroughly but I cannot find anything wrong. It could be something simple as I do not know much about rails. The error I get is the following: NoMethodError in Friends#list Showing /friends/list.rhtml where line #10 raised undefined method `each' for nil:NilClass 7:

Friends#list

8:

9: Names of all the people 10: <% @people.each do |@item| %> 11: Name: <%= person.name %>
12: <% end %> 13: <%=link_to "List", :action => "list" %> Show template trace Request Parameters: None Show session dump Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} Show template parameters The code is: def list @person = Person.find_all end And the view is: Names of all the people <% @people.each do |@item| %> Name: <%= person.name %>
<% end %> I have tried several styles of code. Using for instead of each in the view;Using the list method from the scaffolding straight. But every time I get this response. The data in the MySQL database is pretty simple. What am I doing wrong? When I saw the nilClass I thought that person was not being correctly passed on but because my knowledge of rails is minimal, I'm pretty much stuck. I would appreciate any help or comments. Regards Sven Schott