aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/methods.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-02-12 16:57:47 -0800
committerXavier Noria <fxn@hashref.com>2012-02-12 16:57:47 -0800
commit5cff94fd851f23265b525fe9ce5489c0b28c771c (patch)
treecc73806e633060b32d2b50f24ee46b15421fe47a /activesupport/lib/active_support/inflector/methods.rb
parentdc03a2f56cb9aa7c6b6252311c0ce2fed92f0d06 (diff)
downloadrails-5cff94fd851f23265b525fe9ce5489c0b28c771c.tar.gz
rails-5cff94fd851f23265b525fe9ce5489c0b28c771c.tar.bz2
rails-5cff94fd851f23265b525fe9ce5489c0b28c771c.zip
inflection regexp are meant to be applied once
Diffstat (limited to 'activesupport/lib/active_support/inflector/methods.rb')
-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 79070b4a35..ddd2aca31d 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -92,7 +92,7 @@ module ActiveSupport
# "author_id" # => "Author"
def humanize(lower_case_and_underscored_word)
result = lower_case_and_underscored_word.to_s.dup
- inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
+ inflections.humans.each { |(rule, replacement)| break if result.sub!(rule, replacement) }
result.gsub!(/_id$/, "")
result.gsub!(/_/, ' ')
result.gsub(/([a-z\d]*)/i) { |match|
@@ -311,7 +311,7 @@ module ActiveSupport
if word.empty? || inflections.uncountables.include?(result.downcase[/\b\w+\Z/])
result
else
- rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
+ rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) }
result
end
end