1
0
Fork 0
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:
Rafael Mendonça França 2017-02-24 19:28:41 -05:00
parent 68926798a5
commit 0683552b15
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948

View file

@ -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