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

<h1>Users List</h1>

<table>   <tr>     <th>Name</th>     <th>Age</th>     <th>Designation</th>     <th>Hobby</th>   </tr>

<% @user.each do |user| %>   <tr>     <td><%=h user.name %></td>     <td><%=h user.age %></td>     <td><%=h user.designation %></td>     <td><%=h user.hobby %></td>     <!--<td><%= link_to 'Show', job %></td>     <td><%= link_to 'Edit', edit_job_path(job) %></td>     <td><%= link_to 'Destroy', job, :confirm => 'Are you sure?', :method => :delete %></td>-->   </tr> <% end %> </table>

and my model is this

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

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

Xavier Noria wrote:

lowercase "u".

Xavier Noria wrote:

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

Tony Augustine wrote:

Xavier Noria 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: <th>Hobby</th> 11: </tr> 12: 13: <% @user.each do |user| %> 14: <tr> 15: <td><%=h user.name %></td> 16: <td><%=h user.age %></td>

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 Noria wrote:

<% for user in @users %>

<%=h [user.name](http://user.name/) %> <%=h user.age %> <%end%>

check it out