[Rails] how to describe negative find condition in has_many

2010-02-14 Thread cpr
I have a Teams that has_many Players. I need to get the list of Teams that have no active players (whether they have 0 players or they have a lot of players all of whom are non- active). Can't figure out the conditions for doing this other than subtracting the ones with active players from the

Re: [Rails] how to describe negative find condition in has_many

2010-02-14 Thread Lasse Bunk
Try: named_scope :without_active_players, :conditions = NOT EXISTS(SELECT * FROM players WHERE team_id=teams.id AND status='active'), :order = name Does this work? Lasse 2010/2/14 cpr crosebr...@gmail.com I have a Teams that has_many Players. I need to get the list of Teams that have no