I have this simple code in my user_controller.rb file
#listing all users
def index
@users = User.all # getting all the users!
end
and the view folder i got this:
<!-- View for index action in user's controleer -->
<h1>All users</h1>
<ul class="users">
<% @users.each do |user| %>
<li>
<%= link_to user.name, user %>
</li>
<% end %>
</ul>
The User.all.count returns 13.
Now the code is simple. Why do i get this error?
NoMethodError in Users#index
undefined method `each' for nil:NilClass
Refactor your user_controller.rb to users_controller.rb.
You are calling the wrong controller with the wrong view !