aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-04-07 23:49:28 +0200
committerXavier Noria <fxn@hashref.com>2012-04-07 23:58:44 +0200
commit4b685aad7b5edeb087968c42f815be2bec14b822 (patch)
tree1bb48173c32651381fc0fd7ff7da343416503e75 /activesupport/lib/active_support
parentcf9664adcf06dda719e6e4b1142a4d8b3777c65b (diff)
downloadrails-4b685aad7b5edeb087968c42f815be2bec14b822.tar.gz
rails-4b685aad7b5edeb087968c42f815be2bec14b822.tar.bz2
rails-4b685aad7b5edeb087968c42f815be2bec14b822.zip
revises the regexp used in titleize
The regexp used in titleize matches saxon genitive and other contractions, only to call capitalize on the captured text and have the apostrophe upcased which yields the apostrophe itself. It is more clear that the regexp matches just what it has to match.
Diffstat (limited to 'activesupport/lib/active_support')
-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 54d3b4f5ca..61876d89a9 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -114,7 +114,7 @@ module ActiveSupport
# "TheManWithoutAPast".titleize # => "The Man Without A Past"
# "raiders_of_the_lost_ark".titleize # => "Raiders Of The Lost Ark"
def titleize(word)
- humanize(underscore(word)).gsub(/\b(['’`]?[a-z])/) { $1.capitalize }
+ humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { $&.capitalize }
end
# Create the name of a table like Rails does for models to table names. This method