From d318badc269358c53d9dfb4000e8c4c21a94b578 Mon Sep 17 00:00:00 2001 From: Grey Baker Date: Tue, 23 Dec 2014 02:30:00 +0000 Subject: Don't raise on out-of-range datetimes passed by a user --- .../lib/active_record/attribute_methods/time_zone_conversion.rb | 6 +++++- 1 file changed, 5 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 87274dd4e1..777f7ab4d7 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -12,7 +12,11 @@ module ActiveRecord if value.is_a?(Array) value.map { |v| type_cast_from_user(v) } elsif value.respond_to?(:in_time_zone) - value.in_time_zone || super + begin + value.in_time_zone || super + rescue ArgumentError + nil + end end end -- cgit v1.2.3