Forum: Ruby on Rails Finding items that aren't associated

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
David (Guest)
on 2006-04-19 15:01
Thanks to some advice from the list earlier, I now have a Permission
model that links User and Thing (using has_many and :through).

I can easily get the list of current users by doing the following:

@thing = Thing.find(params[:id])
@current_users = @thing.users

But in my view, I want to construct a select of those users that haven't
had permissions added, so they can be added.  I've tried some pretty
stupid stuff like subtracting @thing.users from User.find :all, but this
doesn't seem to work.

What is the easiest way of picking out all users that aren't currently
associated with the given thing?  Then, I'll create a multi-select and
try to work out how to iterate through all the selected ones and add
their permissions.

This topic is locked and can not be replied to.