You should be able to use ruby to do this:
users_without_groups = User.find_all.collect { |u| u.groups.size == 0 }
Of course, using a Ruby-only statement like this would be less
efficient than a database query if you have to deal with a lot of data.
Duane Johnson
(canadaduane)
On Apr 27, 2005, at 2:47 PM, Andrew wrote:
> Im an italian student and I am developing a rails application and my
> english is
> not good.
> I use 3 tables:
> - users (for the user)
> - groups (the groups for the user)
> - users_groups (link m to n users and groups)
>
> Now i want recovery all the user that have NOT a groups but i do not
> want use an
> ''sql string'', so i ask if exist a method that do this.
> I ask this becouse i want use the best of rails...
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>