Rails Database Query


I'm having trouble creating the right code to query the following:

- I have a table of "trails" and a table of "trailreports"
- "trails" has a "hasmany" relationship with "trailreports"
- "trailreports" has a field "trail_id", "report" and "created_at"

I would like to query the list of "trails" that have the most resent
"trailreports" based on the "created_at" field which is a timestamp.

How do I got about this ?

Thank You,


Something along the lines of...

Trail.find(:all, :include => [:trailreports], :order =>
['trailreports.created_at DESC'])