Retrieving data in a time range with rails
Oct 10, 2013I’m writing this mostly as a reminder to myself, since I keep forgetting this :)
Instead of:
widgets = Widget.where("? <= created_at AND created_at <= ?", time_from, time_to)
do this:
widgets = Widget.where(:created_at => time_from .. time_to)