Rails Association Question...
Posted
by keruilin
on Stack Overflow
See other posts from Stack Overflow
or by keruilin
Published on 2010-03-20T15:42:11Z
Indexed on
2010/03/20
15:51 UTC
Read the original article
Hit count: 118
ruby-on-rails
|associations
I have three models: User, RaceWeek, Race
#
Current associations:
User has_many race_weeks; RaceWeek belongs to user; RaceWeek has many races; Race belongs to RaceWeek
#
So the user_id is a foreign key in RaceWeek and race_week_id is a foreign key in Race.
#
fastest_time is an attribute of the Race model.
#
QUESTION: What's the optimal way to retrieve a list of users who have the top X fastest race times?
© Stack Overflow or respective owner