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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bd3a4af368439803aa37d318f9941a9f?d=identicon&s=25 David (Guest)
on 2006-04-19 13: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.

Thanks.
This topic is locked and can not be replied to.