List of users

Hi all,

I’m creating admin module. in that module i need to get the list of
users and also the projects created by the each user.

No doubt i’m getting the list of users. but i’m not getting the list
of projects done by each user…

This is my code::
<% for user in @users %>
<%=link_to
user.login,:action=>“list”,:controller=>“projects”,:id=>user.id%>
<%end%>
In the controller

def list
@user = User.find_all
@user_pages, @users = paginate :user, :per_page => 20
end

This is the error when i click on the user::

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.[]

Could any please help??

-Harish

Don’t quite understand this. Think we need more details. Is the
controller action below in the Projects controller? What is the view for
the list action in this controller (that is presumably where the prob
is)? What is does the line that contains the nil.[] error on show?

Sorry,

I gave the wrong controller.The below is the correct one::
1 def list
2 [email protected][‘user’][‘id’]
3 @project_pages, @projects= paginate :projects, :per_page => 5,
4 :conditions=>“user_id=#{userId}”
5 user=User.find(userId)
6 end

This is the list.rhtml in users views

<% for user in @users %>
<%=link_to
user.login,:action=>“list”,:controller=>“projects”,:id=>user.id%>
<%end%>

The error is showing in line:2

-Harish

Naga Harish K. wrote:

This is the list.rhtml in users views
-Harish

It’s basically saying there is no ‘user’ in the session variable, and
therefore @session['user] is nil, so by trying to get

@session[‘user’][‘id’] you’re trying to get nil.[‘id’]. Try looking at
how you’ve set the user in the session

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs