about 9 years ago
There is a method provided in rails to convert a string to the camel case.
The method is camelize.
By default camelize converts a string to upper camel case. If we don't specify any argument in camelize method, it will convert the given string to upper camel case.
ex:-
If we want to print the string in lower CamelCase(i.e first character in lower case and first character of other Consecutive words in upper case) then we can pass a lower parameter to the camelize method.
ex:-
If a string is to be converted to the snake case we can use the underscore method provided by Rails. The underscore method converts a string to snake case(i.e words seperated with _)
0 Comment(s)