diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-03-17 10:55:21 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-03-17 10:55:21 +0100 |
commit | 378c8d2c996558aa4108280d5f0db8daf040d0fc (patch) | |
tree | 568c4b8bad12a6b477fc705d2e703c86ce8e1168 /activesupport/lib | |
parent | a0c1c18e4d85e2d95241a1924683b396bd3ae4e5 (diff) | |
download | rails-378c8d2c996558aa4108280d5f0db8daf040d0fc.tar.gz rails-378c8d2c996558aa4108280d5f0db8daf040d0fc.tar.bz2 rails-378c8d2c996558aa4108280d5f0db8daf040d0fc.zip |
fix `number_to_percentage` with `Float::NAN`, `Float::INFINITY`.
Closes #14405.
This is a follow-up to 9e997e9039435617b6a844158f5437e97f6bc107 to restore
the documented behavior.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb index c42354fc83..c45f6cdcfa 100644 --- a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb +++ b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb @@ -32,8 +32,7 @@ module ActiveSupport end formatted_string = - case rounded_number - when BigDecimal + if BigDecimal === rounded_number && rounded_number.finite? s = rounded_number.to_s('F') + '0'*precision a, b = s.split('.', 2) a + '.' + b[0, precision] |