diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-26 09:24:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-26 09:24:45 -0800 |
commit | 7ba3ecca341a7d770738274f78fb85d3e7695619 (patch) | |
tree | 3d14a11ec0fcb9f1a5c54b1763fb0572bf617216 /activesupport/lib | |
parent | 280937578b14b06bcb8b92f13d7243eadc890de7 (diff) | |
download | rails-7ba3ecca341a7d770738274f78fb85d3e7695619.tar.gz rails-7ba3ecca341a7d770738274f78fb85d3e7695619.tar.bz2 rails-7ba3ecca341a7d770738274f78fb85d3e7695619.zip |
global variables may not be set depending on the match. fixes #4703
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index c68a2baee7..1dc2e0487f 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -94,7 +94,10 @@ module ActiveSupport result = lower_case_and_underscored_word.to_s.dup inflections.humans.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } result.gsub!(/_id$/, "") - result.gsub(/(_)?([a-z\d]*)/i) { "#{$1 && ' '}#{inflections.acronyms[$2] || $2.downcase}" }.gsub(/^\w/) { $&.upcase } + result.gsub!(/_/, ' ') + result.gsub(/([a-z\d]*)/i) { |match| + "#{inflections.acronyms[match] || match.downcase}" + }.gsub(/^\w/) { $&.upcase } end # Capitalizes all the words and replaces some characters in the string to create |