I have a user. They have could have many products
The typical link in rails would be www.somesite.com/controller/action/id
what I want is it to look like
www.somesite.com/user_name/product_name
How can I do this using routes.rb
Thank
Mitch
I have a user. They have could have many products
The typical link in rails would be www.somesite.com/controller/action/id
what I want is it to look like
www.somesite.com/user_name/product_name
How can I do this using routes.rb
Thank
Mitch
you can use
match “/:user_name/:product_name” => “products#show”
but be sure to place this at the bottom of your routes file so it will match if not any other routes match.
one big problem i’m seeing with this approach is if a user’s name is the same as one of your controllers.
so you have to consider that.
I have a user. They have could have many products
The typical link in rails would be www.somesite.com/controller/action/id
what I want is it to look like
www.somesite.com/user_name/product_name
How can I do this using routes.rb
You might want to look at friendly_id, that's right up its alley.
Walter