This project is archived and is in readonly mode.
number_to_human_size fails for some values
Reported by Georg Ledermann | January 15th, 2009 @ 06:03 PM | in 2.3.6
For some values, the helper method "number_to_human_size" gives a wrong result. See this examples:
Correct:
number_to_human_size(41500, :precision => 0) => "41 KB"
Wrong:
number_to_human_size(41100, :precision => 0) => "4 KB"
My Environment: * ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-darwin9.1.0] * Rails 2.2.2
Comments and changes to this ticket
-
Georg Ledermann January 15th, 2009 @ 10:22 PM
- Tag changed from 2.2.2, helper, numberhelper, number_to_human_size to 2.2.2, helper, numberhelper, number_to_human_size, patch
Here it's little patch to fix the bug (with tests added). It's a kind of a hack, perhaps someone can find a better way to fix this.
-
Travis Briggs March 19th, 2009 @ 02:01 AM
I fixed this with a different approach, fixing the regex itself. The previous regex was misleading, because since the #{escaped_separator} was inside a zero or one group (ie ()?), it would match trailing zeros after any digit.
I think this is a bit simpler fix, without special casing.
-
Repository May 17th, 2009 @ 06:23 PM
- State changed from new to resolved
(from [98eaa2c6834e418959f2a1a18421e4811167e03b]) Ensure number_to_human_size does not strip zeros from the end [#1763 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/98eaa2c6834e418959f2a1a18421e4... -
Bira September 29th, 2009 @ 08:40 PM
This also affects 2-3-stable (and thus 2.3.4). Would it be possible to apply this patch to that branch as well?
-
Michael Koziarski September 29th, 2009 @ 09:21 PM
- Milestone changed from 2.x to 2.3.6
- State changed from resolved to open
- Assigned user set to Pratik
-
Repository October 17th, 2009 @ 01:38 AM
- State changed from open to resolved
(from [eb30c695444b904d7937c8c12c59da9a8c4d60e5]) Ensure number_to_human_size does not strip zeros from the end [#1763 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/eb30c695444b904d7937c8c12c59da...
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>
People watching this ticket
Attachments
Referenced by
- 1763 number_to_human_size fails for some values (from [eb30c695444b904d7937c8c12c59da9a8c4d60e5]) Ensure ...
- 1763 number_to_human_size fails for some values (from [98eaa2c6834e418959f2a1a18421e4811167e03b]) Ensure ...