Having a bit of a braindead day, can anyone help with this. I have three models: Player, Game, Prediction (Player has_many :games, :through => :prediction)
I want a named_scope that finds games that the current player hasn't already predicted. I started with something like this: named_scope :without_prediction, lambda { |player_id| { :select => "games.*, predictions.*", :joins => "LEFT JOIN predictions ON predictions.game_id = games.id", :conditions => "predictions.player_id IS NULL" } } The problem is that this won't work if ANY player has predicted that game's result. So to be clear if there are games 1, 2 and 3 and players 10 and 11, player 10 has predicted results for all 3 games and player 10 has only predicted 1 and 2, I want a named_scope that returns game 3. It seems like this is something I've done over and over again, but I just can't get it clear in my head today. Any ideas? Cheers, Andy -- Andy Jeffries http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS Company number: 5452840 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.