I would like to know if there is a Rails helper method that removes hyphen from the String and capitalizes it.
For instance, let us turn early-bird
into Early bird
.
I would do
"early-bird".gsub('-', ' ').capitalize
but I would like to know if there is a specific method that does this.
I think .titleize is the closest you get, it will capitalize all words though, not just the first.
'early-bird'.titleize
will give you "Early Bird".
See: http://api.rubyonrails.org/classes/String.html#method-i-titleize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With