This project is archived and is in readonly mode.
number_to_phone broken with empty number and area_code: true
Reported by dvdplm | April 20th, 2011 @ 03:12 PM
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?
Comments and changes to this ticket
-
Diego Carrion April 20th, 2011 @ 06:31 PM
- Assigned user set to Santiago Pastorino
This problem seems fixed in edge. I added a test case case this scenario is important.
-
Santiago Pastorino April 25th, 2011 @ 09:58 PM
- State changed from new to committed
- Importance changed from to Low
Pushed!
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>