[Rails] Noob - Associated Tables Find Query

Peter Baldwin
Wed, 11 Jan 2006 13:45:00 -0000

I''m trying to write a football prediction game.

I have a Matches table and a Predictions table.
Each Match :has_many Predictions, and each Prediction :belongs_to a
Match

Each Match has (amongst other things) a Match.match_date field.
Each Prediction has (amongst other things) a User_id field

I''m trying to get a list of all Predictions a particular User has made
which "belong to" Matches for an arbitrary time period (e.g.
"Time.now
<= now()")
e.g. All "User 1"''s predictions relating to matches from last
week.

Given that the tables are associated, is it possible to do a single
.find query stipulating both the Prediction.User_id and the
Match.match_date, which returns a list of a user''s predictions for the
period?

Thanks in advance