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
Name
Age
Designation
Hobby
<% @user.each do |user| %>
<%=h user.name %>
<%=h user.age %>
<%=h user.designation %>
<%=h user.hobby %>
<% end %>
and my model is this
class User < ActiveRecord::Base
end
can anyone tell how to solve this
i �just �created an application �to list the �primary �details of
userbut it is �showing an error lik this
“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”
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
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.
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