bench_press
bench_press copied to clipboard
formatted_number broken below 1000
Hi, your current implementation of formatted_number
does not work for numbers less than 1000. For example:
formatted_number(999)
=> nil
I see that your implementation borrows heavily from Rails: http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_with_delimiter
The problem? gsub!
can return nil if no substitutions are performed:
"Performs the substitutions of String#gsub in place, returning str, or nil if no substitutions were performed." http://www.ruby-doc.org/core-1.9.3/String.html#method-i-gsub-21
The fix? Change your gsub!
to gsub
. Gotta love the one character fixes.