Ruby on Rails uncapitalize first letter
I'm running Rails 2.3.2. How do I convert "Cool" to "cool" ? I know "Cool".downcase works, but is there a Ruby/Rails method that does the opposite of capitalize , i.e., uncapitalize or decapitalize ? There is no inverse of capitalize , but you can feel free to roll your own: class String def uncapitalize self[0, 1].downcase + self[1..-1] end end tfischbach There is also: "coolat_cat".camelize(:lower) # => "coolCat" You could also do this with a simple sub : "Cool".sub(/^[A-Z]/) {|f| f.downcase } str = "Directly to the south" str[0] = str[0].downcase puts str #=> "directly to the south" There