Jngai1297 Jngai1297 - 4 months ago 10x
Ruby Question

How to replace the last "/" with a dash in a URL

I have this URL in a Sinatra-based application:

<li><a href="/blog/<%= blog.title.tr(' ', '-') %>/<%= blog.slug %>"

When I click on it, the URL looks like this:

I am trying to make the last
also a
too, so it will be:

How do I replace it after the URL has been rendered?

ndn ndn

Given that you started with:

original url generation with colors

The slash is not part of the title, but simply the character in red. Replace it with - in the code:

url generation with slash replace with dash