So I'm trying to do things like so:
today = Date.today - 1
todaysReport = Report.where(:created_at => today).find_by_user_id(user.id)
The problem is created_at is a datetime, so it won't find any matches..Any suggestions?
You probably want something like this:
yesterday = Time.now - 1.day
user = User.find(user_id)
todaysReport = user.reports.where(["created_at >= ? AND created_at <= ?", yesterday.beginning_of_day, yesterday.end_of_day])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With