camelize(term, uppercase_first_letter = true)
Instance Public methods
By default, camelize
converts strings to UpperCamelCase. If
the argument to camelize
is set to :lower
then
camelize
produces lowerCamelCase.
camelize
will also convert '/' to '::' which
is useful for converting paths to namespaces.
1 2 3 4 | 'active_model' .camelize # => "ActiveModel" 'active_model' .camelize( :lower ) # => "activeModel" 'active_model/errors' .camelize # => "ActiveModel::Errors" 'active_model/errors' .camelize( :lower ) # => "activeModel::Errors" |
As a rule of thumb you can think of camelize
as the inverse of
underscore
, though there are cases where that does not hold:
1 | 'SSLError' .underscore.camelize # => "SslError" |
Please login to continue.