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.

NumberHelper#number_with_currency bug

#3529

Problem here:

begin
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.

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

State: stale
Milestone: none
Assigned to: Rohit Arondekar Rohit Arondekar
Importance: none

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • 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.

    June 17th, 2010 @ 08:36 AM

  2. Rohit Arondekar
    Rohit Arondekar
    • 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.

    June 18th, 2010 @ 10:30 AM

  3. hgj
    hgj

    thanks you very much for your information

    April 18th, 2011 @ 07:41 AM