From 3b22df2350dd671436ca5b1e4de4af3df9a8cca2 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sat, 7 Jun 2014 09:38:15 -0600 Subject: Ensure time zones don't change after round trip with array columns The times would be equivalent, even if they were in different time zones. E.g. 12:00 UTC == 5:00 PDT --- .../active_record/attribute_methods/time_zone_conversion.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3