diff options
author | Vasiliy Ermolovich <younash@gmail.com> | 2012-03-26 21:17:25 +0300 |
---|---|---|
committer | Vasiliy Ermolovich <younash@gmail.com> | 2012-03-26 21:18:25 +0300 |
commit | 633ee64e20da05ddbcab67558351733ba511a444 (patch) | |
tree | 1cf5ec448798d605055f1d513192669ed0ff646b /activesupport/lib | |
parent | 1d59caa975a9919a418a08bbaabfa62f0d9dafcd (diff) | |
download | rails-633ee64e20da05ddbcab67558351733ba511a444.tar.gz rails-633ee64e20da05ddbcab67558351733ba511a444.tar.bz2 rails-633ee64e20da05ddbcab67558351733ba511a444.zip |
String#titleize works properly with smart quotes, closes #5584
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 48ea5653c7..4cebad742f 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -1,3 +1,5 @@ +# encoding: utf-8 + require 'active_support/inflector/inflections' module ActiveSupport @@ -112,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])/) { $1.capitalize } end # Create the name of a table like Rails does for models to table names. This method @@ -209,7 +211,7 @@ module ActiveSupport def constantize(camel_cased_word) #:nodoc: names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? - + names.inject(Object) do |constant, name| constant.const_get(name, false) end |