aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/decimal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/type/decimal.rb')
-rw-r--r--activemodel/lib/active_model/type/decimal.rb6
1 files changed, 5 insertions, 1 deletions
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