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

Fix rails 7 deprecation on ActiveRecord::Base.default_timezone #124

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/inventory_refresh/save_collection/saver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,8 @@ def assert_referential_integrity(hash)
true
end

# @return [Time] A rails friendly time getting config from ActiveRecord::Base.default_timezone (can be :local
# or :utc)
def time_now
if ActiveRecord::Base.default_timezone == :utc
Time.now.utc
else
Time.zone.now
end
Time.current
Copy link
Member Author

@jrafanie jrafanie Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agrare this handles if Time.zone is not set (nil) and returns Time.now which should be localtime if not set. If set to utc, it will return utc time via Time.zone.now.

See: https://github.com/rails/rails/blob/v6.1.7.7/activesupport/lib/active_support/core_ext/time/calculations.rb#L39-L41

end

# Enriches data hash with timestamp columns
Expand Down