diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-07 14:57:04 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-07 14:57:04 -0300 |
commit | dc73e39b4d40f0965b000f84568f77f126ec8290 (patch) | |
tree | d9eaacbaea2185f3b3795deeb9a76de868c4d435 /activerecord/lib | |
parent | c6e166b25e60a6594ab9aeba1738a835aa744d3e (diff) | |
parent | 3b22df2350dd671436ca5b1e4de4af3df9a8cca2 (diff) | |
download | rails-dc73e39b4d40f0965b000f84568f77f126ec8290.tar.gz rails-dc73e39b4d40f0965b000f84568f77f126ec8290.tar.bz2 rails-dc73e39b4d40f0965b000f84568f77f126ec8290.zip |
Merge pull request #15561 from sgrif/sg-time-zone-aware-arrays
Ensure time zones don't change after round trip with array columns
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb index 44a679a550..c1c3987cf5 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -10,7 +10,17 @@ module ActiveRecord def type_cast(value) value = @column.type_cast(value) - value.acts_like?(:time) ? value.in_time_zone : value + convert_value_to_time_zone(value) + end + + def convert_value_to_time_zone(value) + if value.is_a?(Array) + value.map { |v| convert_value_to_time_zone(v) } + elsif value.acts_like?(:time) + value.in_time_zone + else + value + end end end |