I'm working with a Rail 5.2 application witch deals with Location records and associated OpeningHour records. The OpeningHour model contains the fields day (enum), starts_at (time) and ends_at (time).
When I run the below, Rails converts Time.now from the local timezone (+08:00) to UTC time before it compared the times with that of any OpeningHour records. Because the starts_at and ends_at fields are stored as times without timezones, the timezones used in the query don't line up.
Location.opening_hours.where("start_at <= ? AND ends_at >= ?", Time.now, Time.now).any?
What's the best way to tell Rails not to convert to UTC time before comparing as the times in the database are already in localtime?
Any help would be much appreciated!