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_phone broken with empty number and area_code: true

#6730

This raises a "TypeError Exception: can't convert nil into String" exception:

    number_to_phone "", area_code: true

These both work (returns ""):

    number_to_phone "", area_code: false
    number_to_phone ""

The reason for the exception is that the #gsub! on line 73 of actionpack/lib/action_view/helpers/number_helper.rb returns nil when there is no match and String#<< is called with a nil argument.

The fix is easy. Replace line 50:

    return nil if number.nil?

...with:

    return nil if number.blank?

Reported by dvdplm · April 20th, 2011 @ 03:12 PM

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

Activity

  1. Vijay Dev
    Vijay Dev

    Can reproduce the error.

    April 20th, 2011 @ 06:23 PM

  2. Diego Carrion
    Diego Carrion
    • Assigned user set to Santiago Pastorino

    This problem seems fixed in edge. I added a test case case this scenario is important.

    April 20th, 2011 @ 06:31 PM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to committed
    • Importance changed from to Low

    Pushed!

    April 25th, 2011 @ 09:58 PM