Take the 2-minute tour ×

I have two values @details and @users as below

@details = ProjectTeamDetail.find_all_by_project_id_and_stage_id($projectID, stage.stage_id)
@users = User.find(:all)

ProjectTeamDetail Model has user_id column

My requirement is to get the users from user table which are not in @details. Hope you understand my requirement.

share|improve this question
i think this link will help you –  user1455116 Oct 3 '12 at 15:12

1 Answer 1

up vote 0 down vote accepted

Rails 3 way:

@details = ProjectTeamDetail.where(project_id: $projectID, stage_id: stage.stage_id)
@users = User.all.where("id NOT IN (?)", @details.map(&:id))
share|improve this answer
Thank you, it worked... –  Vish Oct 4 '12 at 6:20
Also, I'd be sort of wary of using global variables, especially here. It seems almost certainly unnecessary... –  varatis Oct 4 '12 at 13:09

Your Answer


