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.
On Mon, Feb 14, 2011 at 2:04 PM, Mitchell G.
[email protected]wrote:
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
On Feb 14, 2011, at 1:04 AM, Mitchell G. wrote:
I have a user. They have could have many products
The typical link in rails would be
www.somesite.com/controller/action/idwhat 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs