How to get these records in has_and_belongs_to_many relation

i my database i have users and groups, each user can get in different

my db structure:
table groups: id, name, basegroup, firm_id
table users: id, firstname, lastname, email
table groups_users: group_id, users_id

my relation is a many to many:
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
class User < ActiveRecord::Base
has_and_belongs_to_many :groups

i want this
with ajax, first column the user who arent in the group, the second
column those
who are in the group. (is cooler than 2 oldschool selectlists :wink: )

these are my users:
in group: Luc
not in group: Nick, Glenn, Andy

for the second colum i got this in my controller:
@group_users = Group.find(:first, :conditions =>[‘firm_id = ? and id =
@firm_id, @selected_group]).users

and in rhtml:
<% for user in @group_users %>
<%= user.first_name %>

<% end %>

the output it get: Luc
(this is correct for the user who are in the group)

Bur now: who do i get the users Nick, Glenn and Andy???

Thanks in advance

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