Uninitialized constant UsersController::User

i just created an application to list the primary details of
userbut it is showing an error lik this
“uninitialized constant UsersController::User”
this is my controlller

class UsersController < ApplicationController
puts"hiiiiiiiii"
def index
puts"hiiiiiiiii"
@users = User.find(:all)
puts @users
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end

end
end

this is my view file

Users List

<% @user.each do |user| %>

<% end %>
Name Age Designation Hobby
<%=h user.name %> <%=h user.age %> <%=h user.designation %> <%=h user.hobby %>

and my model is this

class User < ActiveRecord::Base
end
can anyone tell how to solve this

On Thu, Feb 25, 2010 at 6:14 AM, Tony A. [email protected]
wrote:

i just created an application to list the primary details of
userbut it is showing an error lik this
“uninitialized constant UsersController::User”

Is the user model defined in app/models/user.rb ?

Xavier N. wrote:

On Thu, Feb 25, 2010 at 6:14 AM, Tony A. [email protected]
wrote:

i �just �created an application �to list the �primary �details of
userbut it is �showing an error lik this
“uninitialized constant UsersController::User”

Is the user model defined in app/models/user.rb ?

yes it is defined in app/models/User.rb ?

Xavier N. wrote:

On Thu, Feb 25, 2010 at 6:28 AM, Tony A. [email protected]
wrote:

yes it is  defined in app/models/User.rb ?
lowercase “u”.
when i changed to lower case it shows an other error

undefined local variable or method `user’ for
#UsersController:0xb6be1a70

On Thu, Feb 25, 2010 at 6:28 AM, Tony A. [email protected]
wrote:

yes it is  defined in app/models/User.rb ?
lowercase “u”.

On Thu, Feb 25, 2010 at 6:46 AM, Tony A. [email protected]
wrote:

Xavier N. wrote:

On Thu, Feb 25, 2010 at 6:28 AM, Tony A. [email protected]
wrote:

yes it is defined in app/models/User.rb ?
lowercase “u”.
when i changed to lower case it shows an other error

I mean, the filename has to be “user.rb”, with a lowercase “u”.

Tony A. wrote:

Xavier N. wrote:

On Thu, Feb 25, 2010 at 6:14 AM, Tony A. [email protected]
wrote:

i �just �created an application �to list the �primary �details of
userbut it is �showing an error lik this
“uninitialized constant UsersController::User”

Is the user model defined in app/models/user.rb ?

yes it is defined in app/models/User.rb ?

i changed but now its showing this error

Showing app/views/users/index.html.erb where line #13 raised:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

Extracted source (around line #13):

10: Hobby
11:
12:
13: <% @user.each do |user| %>
14:
15: <%=h user.name %>
16: <%=h user.age %>

On Thu, Feb 25, 2010 at 7:18 AM, Tony A. [email protected]
wrote:

Extracted source (around line #13):

10: Hobby
11:
12:
13: <% @user.each do |user| %>

Note you put the collection in @users, plural. The variable @user is
unset and thus nil, hence the error. You need to replace @user with
@users in the view.

Xavier N. wrote:

On Thu, Feb 25, 2010 at 7:18 AM, Tony A. [email protected]
wrote:

Extracted source (around line #13):

10: � � Hobby
11: �
12:
13: <% @user.each do |user| %>

Note you put the collection in @users, plural. The variable @user is
unset and thus nil, hence the error. You need to replace @user with
@users in the view.

thanks a lot for replying to ma silly doubts
an wy cya

<% for user in @users %>

<%=h user.name %> <%=h user.age %> <%end%>

check it out
On Thu, Feb 25, 2010 at 11:52 AM, Xavier N. [email protected] wrote:

You have a nil object when you didn’t expect it!
Note you put the collection in @users, plural. The variable @user is
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Thanks:
Rajeev sharma