aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2017-02-24 19:28:41 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-02-24 19:43:09 -0500
commit0683552b15becd6949ab4e125d9790f1b65b7415 (patch)
tree28b10ec7df5c6591d6c764c26c5958c16646782e /activemodel/lib/active_model/type
parent68926798a53bb98e56efe9a96e321a33cc0fa995 (diff)
downloadrails-0683552b15becd6949ab4e125d9790f1b65b7415.tar.gz
rails-0683552b15becd6949ab4e125d9790f1b65b7415.tar.bz2
rails-0683552b15becd6949ab4e125d9790f1b65b7415.zip
Match the behavior of bigdecimal after https://github.com/ruby/bigdecimal/pull/55
Diffstat (limited to 'activemodel/lib/active_model/type')
-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