How to handle timezone differences when querying ActiveRecord timestamps in Rails 7?
Quick question that's been bugging me - I'm building a feature where I'm experiencing unexpected behavior when querying records with timestamp attributes in my Rails 7 application... I have a model called `Event` with a `start_time` attribute, which is stored in UTC in the database. When I retrieve these records and convert them to the local time zone using `in_time_zone`, I'm getting inconsistencies based on the server's time zone configuration. For example, I run the following query: ```ruby Event.where('start_time >= ?', Time.current).each do |event| puts event.start_time.in_time_zone('America/New_York') end ``` On my development environment, the `start_time` shows the correct local time, but on the production server, which is set to a different time zone, the output is incorrect. I have already set the `config.time_zone` in `application.rb` to `Eastern Time (US & Canada)` but it seems to be ignored during the query. I also tried using `Event.all.each` instead of filtering with `where`, but the results remain the same. The database is PostgreSQL, and the ActiveRecord timestamp is indeed set to UTC. I've checked the server's time zone and it matches my expectation. What could be causing this discrepancy, and how can I ensure that the `start_time` is consistently returned in the desired time zone regardless of server settings? This is for a desktop app running on macOS. Cheers for any assistance! I recently upgraded to Ruby 3.11. I've been using Ruby for about a year now. I appreciate any insights!