Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

number_to_human < 1.0 raises TypeError: nil can't be coerced to fixnum

#6576

Passing a value whose magnitude is less than 1.0 raises "TypeError: nil can't be coerced to fixnum":

onyx[~/Developer/bd]$ rake about
About your application's environment
Ruby version              1.9.2 (x86_64-darwin10.6.0)
Rails version             3.0.3
onyx[~/Developer/bd]$ rails console
Loading development environment (Rails 3.0.3)
irb(main):001:0> include ActionView::Helpers::NumberHelper
=> Object
irb(main):002:0> number_to_human(0.5)
TypeError: nil can't be coerced into Fixnum
  from lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/number_helper.rb:475:in `**'
  from lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/number_helper.rb:475:in `number_to_human'
  from (irb):2
irb(main):003:0> number_to_human(-0.5)
TypeError: nil can't be coerced into Fixnum
  from lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/number_helper.rb:475:in `**'
  from lib/ruby/gems/1.9.1/gems/actionpack-3.0.3/lib/action_view/helpers/number_helper.rb:475:in `number_to_human'
  from (irb):3
irb(main):004:0> number_to_human(1.5)
=> "1.5"
irb(main):005:0> number_to_human(-1.5)
=> "-1.5"
irb(main):006:0>

[@José: pardon me if assigning it to you isn't the right protocol -- I'm new to this -- but I'm sure you'll reassign it as needed. Thanks.]

Reported by fearless_fool · March 14th, 2011 @ 06:40 PM

State: resolved
Milestone: none
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Josh Kalderimis
    Josh Kalderimis
    • Tag changed from actionpack, actionview, rails3.0.3 to action_pack, action_view
    • State changed from new to verified
    • Assigned user changed from José Valim to Santiago Pastorino
    • Importance changed from to Low

    I can confirm that this is an issue on master and 3-0-stable.

    The following patch has been supplied for review by Santiago

    https://github.com/joshk/rails/commit/5387a52677d41b41d7431a8e9b78d...

    March 16th, 2011 @ 05:55 PM

  2. Repository
    Repository
    • State changed from verified to resolved

    (from [0eae62525696b57fe7fc4bbb0bf9c0bc7ee4e480]) fixes an issue with number_to_human when converting values which are less than 1 but greater than -1 [#6576 number_to_human < 1.0 raises TypeError: nil can't be coerced to fixnum state:resolved]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/0eae62525696b57fe7fc4bbb0bf9c...

    March 16th, 2011 @ 06:12 PM

  3. Repository
    Repository

    (from [7c8a5f5759a0c63945d133280fb78deaa86b65b9]) fixes an issue with number_to_human when converting values which are less than 1 but greater than -1 [#6576 number_to_human < 1.0 raises TypeError: nil can't be coerced to fixnum state:resolved]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/7c8a5f5759a0c63945d133280fb78...

    March 16th, 2011 @ 06:13 PM