From 0683552b15becd6949ab4e125d9790f1b65b7415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 24 Feb 2017 19:28:41 -0500 Subject: Match the behavior of bigdecimal after https://github.com/ruby/bigdecimal/pull/55 --- activemodel/lib/active_model/type/decimal.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/type/decimal.rb b/activemodel/lib/active_model/type/decimal.rb index b4ba8d4b1f..e6805c5f6b 100644 --- a/activemodel/lib/active_model/type/decimal.rb +++ b/activemodel/lib/active_model/type/decimal.rb @@ -24,7 +24,11 @@ module ActiveModel when ::Numeric BigDecimal(value, precision || BIGDECIMAL_PRECISION) when ::String - value.to_d rescue BigDecimal(0) + begin + value.to_d + rescue ArgumentError + BigDecimal(0) + end else if value.respond_to?(:to_d) value.to_d -- cgit v1.2.3