Hi
I have a table containing timestamped weather data.  When I wish to
show the weather for a day I use a named scope:
  named_scope :by_time_range, lambda{ |time_min, time_max|
  {:conditions => [''measured_at >= ? and measured_at <=
?'',
time_min.utc, time_max.utc] } }
where time_min and max are midnight to midnight.  If there is a sample
at the midnight at the start of the day then all is well, but if there
is not then I have no reference point for the start of the day, so I
would like to include in the find the last sample before midnight if
there is not one at midnight.
I can see how to do this as two finds, one finding the samples where
measured_at > time_min and <= time_max and then concatenating this
with the last sample from a find where measured_at <= time_min, which
will give me the one at midnight or the last one before midnight.
Is there a way I can do this within one find?
Colin
-- 
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.