aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-10-04 08:41:03 +0930
committerMatthew Draper <matthew@trebex.net>2014-10-04 08:41:03 +0930
commitcad635995ca945d4137d0aab64d46313aee4f556 (patch)
treedd3326dad9ecdc049fd7dd9f45eb9e214f56b3f7
parentcf662783016462ce03ffbf76d09ad826ef5242ba (diff)
downloadrails-cad635995ca945d4137d0aab64d46313aee4f556.tar.gz
rails-cad635995ca945d4137d0aab64d46313aee4f556.tar.bz2
rails-cad635995ca945d4137d0aab64d46313aee4f556.zip
:heart: 1.9
-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 5b75dd65d0..0e3c8517d1 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])|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_'}#{$2.downcase}" }
+ word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$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!("-", "_")