Blaz
1
When I want to see my users, then I get:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
Extracted source (around line #3):
1: <% @page_title = “Spisek uporabnikov” -%>
2:
3: <% for user in @all_users %>
4:
5: <%= user.name %> |
that’s list_users.rhtml ^
and login_controller.rb Ë?
def list_users
@all_users = User.find_all
end
And I don’t understand what is wrong here … ??
Blaz
2
Blaz wrote:
3: <% for user in @all_users %>
And I don’t understand what is wrong here … ??
Looks like @all_users contains no users.
Try this:
<%if @all_users.nil?
I have no users
<%else
for user in @all_users%>
do your html stuff
<%end
<%end%>
Blaz
3
David C. wrote:
Blaz wrote:
3: <% for user in @all_users %>
And I don’t understand what is wrong here … ??
Looks like @all_users contains no users.
Try this:
without the typos
<%if @all_users.nil?%>
I have no users
<%else
for user in @all_users%>
do your html stuff
<%end
end%>
Blaz
4
Thanx, but I just solved my problem.
there was
def /
end
before
def list_users
@all_users = User.find_all
end
and when i was remove that def / , all run fine.