mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Match the behavior of bigdecimal after https://github.com/ruby/bigdecimal/pull/55
This commit is contained in:
parent
68926798a5
commit
0683552b15
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue