diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2016-03-31 02:11:19 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2016-03-31 19:52:10 +0300 |
commit | f2489f493b794ee83a86e746b6240031acb8994e (patch) | |
tree | 2cf9a32c4e351373ff68e526ba8c042dbf8e29b4 /activesupport/lib/active_support/inflector/methods.rb | |
parent | a564fecbd0c96815664067b727817045459cae98 (diff) | |
download | rails-f2489f493b794ee83a86e746b6240031acb8994e.tar.gz rails-f2489f493b794ee83a86e746b6240031acb8994e.tar.bz2 rails-f2489f493b794ee83a86e746b6240031acb8994e.zip |
Fix method String#upcase_first
Diffstat (limited to 'activesupport/lib/active_support/inflector/methods.rb')
-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 3fbc19ddf8..f94e12e14f 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -142,9 +142,11 @@ module ActiveSupport # Converts just the first character to uppercase. # - # 'what a Lovely Day'.upcase_first # => "What a Lovely Day" + # upcase_first('what a Lovely Day') # => "What a Lovely Day" + # upcase_first('w') # => "W" + # upcase_first('') # => "" def upcase_first(string) - string[0].upcase.concat(string[1..-1]) + string.length > 0 ? string[0].upcase.concat(string[1..-1]) : '' end # Capitalizes all the words and replaces some characters in the string to |