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?
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?
In Rails 5.1 and greater, you can use all_day instance method like this:
today = Date.today - 1
todaysReport = Report.where(created_at: today.all_day).find_by_user_id(user.id)