instance method String#underscore

View source on GitHub →

String#underscore() → String

Converts a camelized string into a series of words separated by an underscore (_).

Example
'borderBottomWidth'.underscore();
// -> 'border_bottom_width'
Note

Used in conjunction with String#dasherize, String#underscore converts a DOM style into its CSS equivalent.

'borderBottomWidth'.underscore().dasherize();
// -> 'border-bottom-width'