I think for this I would find all the questions (and eager load the
answers for those questions) and then sort the array. e.g.
class Question < ActiveRecord::Base
has_many :answers, :order => "answers.date DESC"
def latest_date_including_answers
if self.answers.blank?
return self.date
else
return answers.first.date
end
end
def self.newest_including_answers
find(:all, :include => :answers).sort{|a,b|
a.latest_date_including_answers <=>
b.latest_date_including_answers
}
end
end
The latest_date_including_answers method assumes that answers always
come after the question is asked (since it doesnt compare answer.date
to question.date).