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_currency(101.00) returns $110

#4527

The title says it all.

Using Rails 3 Beta 3

Reported by Mike (at coverallcrew) · May 3rd, 2010 @ 10:32 PM

State: invalid
Milestone: none
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: none

Activity

  1. Adam Roth
    Adam Roth

    From a view:

    <%= number_to_currency(101.00) %>
    

    outputs: $101.00

    ...and from the console:

    foo = ActionView::Base.new
    foo.extend ActionView::Helpers::NumberHelper
    foo.number_to_currency(101.00)
    => "$101.00"
    

    Tested Rails "3.0.0.beta3"

    Are you passing in any additional parameters to number_to_currency?

    May 4th, 2010 @ 04:22 AM

  2. Mike (at coverallcrew)
    Mike (at coverallcrew)

    I'm not passing anything else. Tried from the console, and mine fails with $110.00. Are you running the gem version of Rails 3 Beta 3 perhaps?

    May 4th, 2010 @ 06:06 AM

  3. Anil Wadghule
    Anil Wadghule

    Mike, can you give pastie of your console showing it is failing along with Ruby version you are using.

    May 4th, 2010 @ 06:35 AM

  4. Santiago Pastorino
    Santiago Pastorino
    • Assigned user set to Santiago Pastorino

    With the latest code from edge using 1.8.7 runs nice

    May 4th, 2010 @ 07:08 AM

  5. Mike (at coverallcrew)
  6. Neeraj Singh
    Neeraj Singh

    I tested it with rails3 edge. And this is the result I got in console.

    => "$101.00"

    May 4th, 2010 @ 04:36 PM

  7. Mike (at coverallcrew)
    Mike (at coverallcrew)

    Here is my Gemfile. Perhaps it is something here that is conflicting.

    http://pastie.org/private/eyacxhg7bhrp9unxchq9g

    May 4th, 2010 @ 05:26 PM

  8. Josh Kalderimis
    Josh Kalderimis

    You might want to go through and comment out gem by gem in your Gemfile to see if any are causing this issue.

    May 10th, 2010 @ 11:28 AM

  9. Santiago Pastorino
    Santiago Pastorino

    Yes, first you should try with a fresh application and if all is working could be a bug related with one of the plugins you are using.

    May 10th, 2010 @ 02:29 PM

  10. Kim Toms
    Kim Toms

    As far as I can tell, it's in BigDecimal.

    Kims-Mac:bug4278 kim$ irb
    irb(main):001:0> RUBY_VERSION
    => "1.8.7"
    irb(main):002:0> RUBY_PATCHLEVEL
    => 173
    irb(main):003:0> require 'bigdecimal'
    => true
    irb(main):004:0> BigDecimal.new('10100')
    => #<BigDecimal:10039f778,'0.11E5',8(12)>
    irb(main):005:0>
    

    May 10th, 2010 @ 04:51 PM

  11. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to invalid

    So ok update you Ruby version guys patchlevel 249 doesn't have this problem

    May 10th, 2010 @ 05:39 PM

  12. Mike (at coverallcrew)
    Mike (at coverallcrew)

    Hi Kim,

    Yeah, it looks like BigDecimal is doing something funky. I have the same version and patchlevel and same result as you.

    May 10th, 2010 @ 05:40 PM

  13. Andrew White
    Andrew White

    The last update to Snow Leopard (10.6.3) shipped with a version of ruby 1.8.7 with a known bug in BigDecimal. Apple really dropped the ball on this one - the fixed version has been available since June 2009.

    One more reason to use RVM.

    May 11th, 2010 @ 02:50 PM