Reputation: 1151
I know I can convert "hello_world"
to "hello-world"
by calling "hello_world".gsub('_', '-')
. But is there a string method for this built into Rails, something equivalent to underscore? Sometimes it's difficult to find such methods if you don't know the name!
Upvotes: 5
Views: 1737
Reputation: 14890
dasherize
right there on the same page
"hello_world".dasherize # => 'hello-world'
Upvotes: 9