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

Check time_zone_aware_types #198

Open
codez opened this issue Jun 2, 2021 · 3 comments
Open

Check time_zone_aware_types #198

codez opened this issue Jun 2, 2021 · 3 comments

Comments

@codez
Copy link

codez commented Jun 2, 2021

When testing if a certain attribute is time zone aware in the validator, also check the value of ActiveRecord::Base.time_zone_aware_types.

We have ActiveRecord::Base.time_zone_aware_types = [:datetime], hence :time types are not time zone aware. When validating times, they are still converted to CET, giving wrong validation errors.

This problem arised with the upgrade to 5.0, because skip_time_zone_conversion_for_attributes is empty in our case, which leads to the attribute being interpreted as time zone aware wrongly. In version 4.1, timeliness_attribute_timezone_aware? returned false by default.

@adzap
Copy link
Owner

adzap commented Jun 4, 2021

What version of Rails/ActiveRecord are you using?

@codez
Copy link
Author

codez commented Jun 4, 2021

6.1.3.2

@camilova
Copy link

camilova commented Sep 20, 2021

Hi, I have this same problem because we have disabled time zone award system-wide with the config option config.active_record.time_zone_aware_attributes = false and because the method time_zone_aware? in validator.rb here does not check if this config flag is false and then return true, making the parsing wrong.

I wrote a patch PR for this #202

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

No branches or pull requests

3 participants