[Rails] Re: Tricky find on associated conditions

2009-07-08 Thread Gavin Morrice
Sweet - wasn't aware of that one Thanks :) Gavin http://handyrailstips.com -- 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

[Rails] Re: Tricky find on associated conditions

2009-07-08 Thread Carsten Gehling
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) w

[Rails] Re: Tricky find on associated conditions

2009-07-08 Thread Gavin Morrice
Carsten Gehling wrote: > My head is spinning a bit this morning - can somebody help me with this? > > Given these two models with the following associations: > > class Article < ActiveRecord::Base > belongs_to :category > > - has an attribute called "published_on" > end > > class Category