Reputation: 3216
I'm developing a marketplace app where vendors can list items to sell. I have two routes that I need to customize.
1) My product listing routes are based on resources listings
- this makes the product show page route be /listings/:id
. For seo purposes, I want the product name to be part of the route so /listings/:id/:name
. But since I'm using resources listings
, I'm not sure how to specify that I want to change the show page route.
2) My vendor page (which shows for vendor specific listings) route is get '/listings/s/:id' => 'listings#vendor', as: 'vendor'
. I want to add the vendor name to the route so it is /listings/:vendor/:id
- the vendor name is in the User model. The Listing model has a user_id foreign key. How do I reference the vendor name in the listing route?
Upvotes: 1
Views: 50
Reputation: 3243
You want to use slugs, not complicated routes, see this gem: https://github.com/norman/friendly_id
Upvotes: 2