aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector
diff options
context:
space:
mode:
authorJason <jasonmichaelroth@gmail.com>2011-05-07 13:21:00 -0600
committerJason <jasonmichaelroth@gmail.com>2011-05-07 13:21:00 -0600
commit3880ab0d7ca8d38c870279a1ad3495fba1c2995a (patch)
tree03e34adb1e3c33fb1640a9b802c0058c686396ee /activesupport/lib/active_support/inflector
parent7ec3f33e3a5aa6d561ce34ae36c3beb495a0b6c7 (diff)
downloadrails-3880ab0d7ca8d38c870279a1ad3495fba1c2995a.tar.gz
rails-3880ab0d7ca8d38c870279a1ad3495fba1c2995a.tar.bz2
rails-3880ab0d7ca8d38c870279a1ad3495fba1c2995a.zip
ordinalize negative numbers patch
Applied patch by Amir Manji https://github.com/rails/rails/issues/437#issuecomment-1116045 Signed-off-by: Jason <jasonmichaelroth@gmail.com>
Diffstat (limited to 'activesupport/lib/active_support/inflector')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index de49750083..dd2beef89d 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -136,10 +136,10 @@ module ActiveSupport
# ordinalize(1002) # => "1002nd"
# ordinalize(1003) # => "1003rd"
def ordinalize(number)
- if (11..13).include?(number.to_i % 100)
+ if (11..13).include?(number.to_i.abs % 100)
"#{number}th"
else
- case number.to_i % 10
+ case number.to_i.abs % 10
when 1; "#{number}st"
when 2; "#{number}nd"
when 3; "#{number}rd"