Say I have a series of nested resources (Magazine
, Edition
, and Ad
) in a Rails application, such that magazines have many editions, which subsequently have many ads.
How can I do a query to produce all ads in all editions of a given magazine, and then order them, for example, by date created?
Ideally, I'd like to produce an array with all the results using a single SQL query, as opposed to doing a query for each edition and then combining the subsequent arrays.