In case someone looking for case when he need to apply underscore to string with spaces and want to convert them to underscores as well you can use something like this
'your String will be converted To underscore'.parameterize.underscore
#your_string_will_be_converted_to_underscore
Or just use .parameterize('_') but keep in mind that this one is deprecated
'your String will be converted To underscore'.parameterize('_')
#your_string_will_be_converted_to_underscore