diff options
author | Ben Sharpe <bsharpe@gmail.com> | 2010-09-02 08:05:23 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-09-05 09:56:13 -0300 |
commit | b80cf265be083b158c915ccbb4af7ce5ac05aec7 (patch) | |
tree | 7a31965b1528e45b15031ffad587c362a84ba6ba /actionpack/lib/action_view | |
parent | 708ee9c5ac6ef3ded22a716914a2c46136b5dfe0 (diff) | |
download | rails-b80cf265be083b158c915ccbb4af7ce5ac05aec7.tar.gz rails-b80cf265be083b158c915ccbb4af7ce5ac05aec7.tar.bz2 rails-b80cf265be083b158c915ccbb4af7ce5ac05aec7.zip |
Fix number_to_human(0) exception [#5532 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/number_helper.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 9dc47272b0..7b3751de46 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -459,7 +459,8 @@ module ActionView raise ArgumentError, ":units must be a Hash or String translation scope." end.keys.map{|e_name| DECIMAL_UNITS.invert[e_name] }.sort_by{|e| -e} - number_exponent = Math.log10(number).floor + number_exponent = 0 + number_exponent = Math.log10(number).floor if number != 0 display_exponent = unit_exponents.find{|e| number_exponent >= e } number /= 10 ** display_exponent |