Given the following simple model:
A page has many sections
A section has many entries
Each entry has a time_stamp
I can easily find all the entries of a section sorted by time_stamp:
(:all, :order => “time_stamp”)
But what if I need all the entries of a page sorted by time_stamp?
One thought was to search across all entries and use Array.include? to constrain the entries to the sections of a page:
section_ids = 
page.sections.each do |section|
section_ids << section.id
(:all, :conditions => ["?.include? section_id", section_ids], :order => “time_stamp”)
I can’t get this to work because I can’t find a way to escape the second question mark.
But perhaps there is a better way of doing this?