I would do something like ...
someday = Date.today Foo.where( :created_at => (someday)..(someday + 1.day) )
This captures all created_at dates between midnight on someday and someday + 1 . This is included (so it will include Foo, created at midnight +1 day), but can be “good enough” for your needs without falling into timestamps.
For convenience, I would wrap it as scope
scope :on_day, ( lambda do |someday| where( :created_at => (someday)..(someday + 1.day) ) end )
So,
Foo.on_day( Date.yesterday ).count
well read.
razorhead
source share