Skip to content
This repository
Browse code

Fixed NumberHelper#number_with_delimiter to use "." always for splitt…

…ing the original number, not the delimiter parameter (closes #7389) [ceefour]

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6045 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 7e33de46e5079c29509db35e961af882840e5c17 1 parent fe42e6c
David Heinemeier Hansson dhh authored
2  actionpack/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* Fixed NumberHelper#number_with_delimiter to use "." always for splitting the original number, not the delimiter parameter #7389 [ceefour]
  4 +
3 5 * Autolinking recognizes trailing and embedded . , : ; #7354 [Jarkko Laine]
4 6
5 7 * Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268. [imajes]
10 actionpack/lib/action_view/helpers/number_helper.rb
@@ -94,16 +94,16 @@ def number_to_percentage(number, options = {})
94 94 end
95 95
96 96 # Formats a +number+ with grouped thousands using +delimiter+. You
97   - # can customize the format in the +options+ hash.
98   - # * <tt>:delimiter</tt> - Sets the thousands delimiter, defaults to ","
99   - # * <tt>:separator</tt> - Sets the separator between the units, defaults to "."
  97 + # can customize the format using optional <em>delimiter</em> and <em>separator</em> parameters.
  98 + # * <tt>delimiter</tt> - Sets the thousands delimiter, defaults to ","
  99 + # * <tt>separator</tt> - Sets the separator between the units, defaults to "."
100 100 #
101 101 # number_with_delimiter(12345678) => 12,345,678
102 102 # number_with_delimiter(12345678.05) => 12,345,678.05
103   - # number_with_delimiter(12345678, :delimiter => ".") => 12.345.678
  103 + # number_with_delimiter(12345678, ".") => 12.345.678
104 104 def number_with_delimiter(number, delimiter=",", separator=".")
105 105 begin
106   - parts = number.to_s.split(separator)
  106 + parts = number.to_s.split('.')
107 107 parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
108 108 parts.join separator
109 109 rescue

0 comments on commit 7e33de4

Please sign in to comment.
Something went wrong with that request. Please try again.