I am trying to simply add a '/' at the end of this string. What is the best way to do this?
>> params[:id]
"shirts"
I would like to make params[:id] == "shirts/"
. How do I add a /
at the end of that string?
Simplest:
params[:id] = params[:id] + '/'
or
params[:id] += '/'
Moar fancy:
params[:id] << '/'
Yet another way to do this:
params[:id].concat '/'
If you really really for some bizzare reason insist on gsub:
params[:id].gsub! /$/, '/'
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