This project is archived and is in readonly mode.

#3529 ✓stale

NumberHelper#number_with_currency bug

Reported by Vojto | December 1st, 2009 @ 02:19 PM

Problem here:

format.gsub(/%n/, number_with_precision(number,

:precision => precision,
:delimiter => delimiter,
:separator => separator)

).gsub(/%u/, unit) rescue
number end

If precision, delimiter, separator are nil, then number_with_precision returns Fixnum, which causes whole block to fail, because gsub accepts only String.

Fix is easy, there should be .to_s right after number_with_precision call, and I think this way begin/rescue won't be needed at all here.

Comments and changes to this ticket

  • Rohit Arondekar

    Rohit Arondekar June 17th, 2010 @ 08:36 AM

    • Assigned user set to “Rohit Arondekar”

    Vojto, I can't find that helper in the api docs of either Rails 2.x or Rails 3. I believe it has been renamed to number_to_currency. Can you confirm if this issue still exists? If it doesn't I can close this ticket.

  • Rohit Arondekar

    Rohit Arondekar June 18th, 2010 @ 10:30 AM

    • State changed from “new” to “stale”

    Now number_with_precision raises an exception if any of the options to number_to_currency are nil. If you still feel that this needs fixing please reopen the ticket with a patch.

  • hgj

    hgj April 18th, 2011 @ 07:41 AM

    thanks you very much for your information

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>