aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-26 09:24:14 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-26 09:24:14 -0800
commitef7fc6ebb3fc7688c11ee664b9748b6c0ed4eb7b (patch)
tree477852cf4ee94d2cb36abf2d46f1e8cc0e3ec2e0 /activesupport/lib
parentad1b2aa4edff73268d191c0a7e00cb6bb78139f1 (diff)
downloadrails-ef7fc6ebb3fc7688c11ee664b9748b6c0ed4eb7b.tar.gz
rails-ef7fc6ebb3fc7688c11ee664b9748b6c0ed4eb7b.tar.bz2
rails-ef7fc6ebb3fc7688c11ee664b9748b6c0ed4eb7b.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.rb5
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 c245b5b53c..9b0f0e859a 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