Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change AR default_timezone to :utc since it's the default for AR::Railtie #4573

Merged
merged 1 commit into from
Jan 21, 2012

Conversation

amatsuda
Copy link
Member

This is an already known inconsistency reported here https://rails.lighthouseapp.com/projects/8994/tickets/5679-activerecordbasedefault_timezone

Since AR 3.0, AR::Base.default_timezone is set to :utc in Railtie https://github.com/rails/rails/blob/c05f3b0e4f/activerecord/lib/active_record/railtie.rb#L48
then overridden to :local at Base or Core
https://github.com/rails/rails/blob/c05f3b0e4f/activerecord/lib/active_record/core.rb#L51

Because of this, AR::Base.default_timezone value defers for a Rails app

% bundle e rails runner 'p ActiveRecord::Base.default_timezone'
:utc

and a Ruby script that doesn't load AR::Railtie

% ruby -e "require 'active_record'; p ActiveRecord::Base.default_timezone"
:local

The next major version up must be the best timing for fixing this inconsistency, so I propose this patch again for 4.0.

josevalim added a commit that referenced this pull request Jan 21, 2012
change AR default_timezone to :utc since it's the default for AR::Railtie
@josevalim josevalim merged commit a50382c into rails:master Jan 21, 2012
yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Jul 15, 2016
Since Rails 4 this value changed from :local to :utc
rails/rails#4573

There are 7 specs which explicitly need
to set `ActiveRecord::Base.default_timezone = :local`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants