I have three models:
- User
- Award
- Trophy
The associations are:
- User has many awards
- Trophy has many awards
- Award belongs to user
- Award belongs to trophy
- User has many trophies through awards
Therefore, user_id is a fk in awards, and trophy_id is a fk in awards.
In the Trophy model, which is an STI model, there's a trophy_type column. I want to return a list of users who have been awarded a specific trophy -- (trophy_type = 'GoldTrophy'). Users can be awarded the same trophy more than once. (I don't want distinct results.)
Can I use a named_scope? How about chaining them? Or do I need to use find_by_sql? Either way, how would I code it?