Reputation: 11299
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
Upvotes: 4
Views: 2618
Reputation: 15224
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) %>
Upvotes: 6