adamlowe
(Adam Lowe)
1
I have no idea why but I’m receiving the following error after 1:53 into the week three video:
NoMethodError in Users#index
undefined method `each’ for nil:NilClass
app/views/users/index.html.erb contains the following:
<%= @users.each do |user| %>
<div><%= link_to user.username, user %></div>
<% end %>
I tried to go from the begining of the video with no luck.
Check if @users was defined in your index action inside your controller.
adamlowe
(Adam Lowe)
3
class UsersController < ApplicationController
respond_to :html
def index
@user = User.all
end
.
.
.
end
This should be @users. You have @user.
adamlowe
(Adam Lowe)
5
Ah, thanks! I was pulling my hair out.