Is this possible?
def to_param
"#{id}%2F#{slug}"
end
This works in Chrome and Safari, but if Firefox you see the "%2F" in the address bar. Is there a cleaner way?
This is indeed an old post, but I want to build a bit on it.
If you don't want to have to handle an slug variable in your params, you really need to define that method to_param in your model
def to_param "#{id}/#{title}" end
and set a route like so:
resources :posts, :id => /[0-9]+\/.+/
That way your link definition looks quite like a normal one:
link_to post.title, post_url(post)
Very simple: http://www.miguelsanmiguel.com/2011/03/17/slug-that-slash
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