I have a simple problem that I am sure has a simple answer, but my brain will not produce the answer. I have a table (segments) that has a start_time field. Given a specific time I want to find the last segment with a start_time <= time and the first one with start_time > time, so Segment.order(:start_time).where( "start_time <= ?", time).last and Segment.order(:start_time).where( "start_time > ?", time).first I feel sure it must be possible to do this in one query, but I can't see how.
Any suggestions gratefully received. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLugPcn_jGepdBuR-KgTudbbNUzT-Ssgw-24iNQmKYix6w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

