Articles.find(:all, :include => [:users, :assets])
This will return all Articles (you don't have a where clause) and will
eagerly load any associated users and assets.
The Articles wil be distinct values (i.e. only one object will be
returned for each primary key value)
Is that what you are trying to do?
And that's EXACTLY what the :includes option on find is for. Assuming
that Article and Asset each have a name method which produces what you
want to print:
Article.find(:all, :include => :assets).each do | article|
puts article.name
# The following will not perform an additional query since the
assets were preloaded
puts article.assets.map {|asset| "- #{asset.name}"}.join(" ")
end
Of course the name method is just an example, the point is that
:include will preload the assets so you can use them without a
separate sql query to get the assets for each Article.