I need to make the first character of every word uppercase, and make the rest lowercase...
manufacturer.MFA_BRAND.first.upcase
is only sett
I used this for a similar problem:
'catherine mc-nulty joséphina'.capitalize.gsub(/(\s+\w)/) { |stuff| stuff.upcase }
This handles the following weird cases I saw trying the previous answers:
"hello world".split.each{|i| i.capitalize!}.join(' ')
If you are trying to capitalize the first letter of each word in an array you can simply put this:
array_name.map(&:capitalize)
Look into the String#capitalize method.
http://www.ruby-doc.org/core-1.9.3/String.html#method-i-capitalize
Another option is to use a regex and gsub, which takes a block:
'one TWO three foUR'.gsub(/\w+/, &:capitalize)
"hello world".titleize
which should output "Hello World".