I have a custom vanity URL setup, ala GitHub:
http://foo.com/:user/:stuff
I have routes to handle this as well:
match '/:user/:stuff', to: 'stuffs#show'
How can I make link_to
work with this route for stuff
?
link_to @stuff.name, @stuff
You can make it through a route alias:
match '/:user/:stuff' => 'stuffs#show', :as => 'users_stuff'
And in your view call it normally, passing the two parameters:
<%= link_to 'Show', users_stuff_path(current_user,3) %>
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