S
Sven Schott
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: <h1>Friends#list</h1>
8: <p>
9: <b>Names of all the people</b>
10: <% @people.each do |@item| %>
11: Name: <%= person.name %><br/>
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:
<b>Names of all the people</b>
<% @people.each do |@item| %>
Name: <%= person.name %><br/>
<% 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
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: <h1>Friends#list</h1>
8: <p>
9: <b>Names of all the people</b>
10: <% @people.each do |@item| %>
11: Name: <%= person.name %><br/>
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:
<b>Names of all the people</b>
<% @people.each do |@item| %>
Name: <%= person.name %><br/>
<% 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