This project is archived and is in readonly mode.
config.time_zone not setting default_timezone for AR, causing errors with Postgres
-
MikZ
- Tag set to time zone, activerecord, postgres, postgresql, timezone
I've run into this issue too. My views depends on time zone settings and postgres adapter wrongly set it to UTC.
ActiveRecord::Base.default_timezone is :utc even if it isn't configured. -
JackC
I have the same issue as MikZ. Wrong time zone setting is breaking a view that does time calculations.
A workaround appears to be adding the following line to application.rb:
config.active_record.default_timezone = :local
This fixes the view, and the rest of my app seems unaffected.
-
MikZ
i've figured this out
rails are setting accessors with automatic timezone conversions
when you override acessor (with table colum) you will get to serious problemswhen leaving rails default (or setting timezone) you will get nice results
but if you override accessors you will get to serious problems with thatso: don't ever override "time" attibutes' accessors
-
Steve Madsen
I am experiencing this bug, too.
I found it after I noticed that some of my reporting, which groups records by date, was returning erroneous results. PostgreSQLAdapter is setting the connection's time zone to UTC, which throws off queries that follow this pattern:
SELECT DATE(created_at AT TIME ZONE 'UTC') ...If the connection is properly set to the local time zone, the AT TIME ZONE part will adjust to local time before truncating to a date. If the connection is set to UTC, PostgreSQL thinks that no adjustment is needed, and times when the UTC date and local time date are different result in the wrong answer.
-
rails
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
rails
- State changed from open to stale