aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/methods.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-09-06 04:56:25 +0930
committerMatthew Draper <matthew@trebex.net>2014-09-06 04:56:25 +0930
commitccbb48196efe06a0c1c360951caff74ee74a8d14 (patch)
treef1f719f0ada69e57ef441c8f398ad3c44751d067 /activesupport/lib/active_support/inflector/methods.rb
parent9576605dfdb4b65210e26036d04a6984f1fcf3a8 (diff)
downloadrails-ccbb48196efe06a0c1c360951caff74ee74a8d14.tar.gz
rails-ccbb48196efe06a0c1c360951caff74ee74a8d14.tar.bz2
rails-ccbb48196efe06a0c1c360951caff74ee74a8d14.zip
Fix for inflector's incorrect camelCase replacement for acronyms
Fixes #8015, #9756. [Fred Wu & Matthew Draper]
Diffstat (limited to 'activesupport/lib/active_support/inflector/methods.rb')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index 53022de549..f35e71ce81 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -91,7 +91,7 @@ module ActiveSupport
def underscore(camel_cased_word)
return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
word = camel_cased_word.to_s.gsub('::', '/')
- word.gsub!(/(?:([A-Za-z\d])|^)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
+ word.gsub!(/(?:([A-Za-z\d])|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
word.tr!("-", "_")