Can anyone give me the sql for this?  I can't quite figure it out.  I
want to find the most recent record from the states table that is before
a given date, and if that doesn't exist, the first one *after* that
date?

Currently i'm doing it as two seperate finds, like this, but i need to
combine it into one sql call if i can.

      self.states.find(:first, :conditions => ["created_at < ?", time],
:order => "created_at desc") ||
        self.states.find(:first, :conditions => ["created_at > ?",
time], :order => "created_at")

thanks, max
-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to