ruby on rails - Comparing a Date to the Datetime Created_at in rails3 -
so i'm trying things so:
today = date.today - 1 todaysreport = report.where(:created_at => today).find_by_user_id(user.id)
the problem created_at datetime, won't find matches..any suggestions?
you want this:
yesterday = time.now - 1.day user = user.find(user_id) todaysreport = user.reports.where(["created_at >= ? , created_at <= ?", yesterday.beginning_of_day, yesterday.end_of_day])
Comments
Post a Comment