Gavin Morrice wrote:

> 
> Off the top of my head, try:
> 
> Category.all :include => :articles, :order => "articles.published_on 
> DESC"

Works like a charm - thanks!

Now that you got my head pointed in the right direction ;-) I noticed, 
that :joins does the same job for me (ie. same result) with some slight 
internal difference:

:include - uses LEFT OUTER JOIN and explicitely selects all attributes 
from both tables (specifying each attribute by name)

:joins - uses INNER JOIN and only selects categories.*

While it probably won't matter with my 300-400 articles, in a larger 
dataset I should think, that :joins is the faster of the two.

Thank you for your help. :-)

- Carsten
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to