Reputation: 522
I'm using FriendlyID to produce slugs for some of my models.
To use the example provided in the FriendlyID docs ( http://rubydoc.info/github/norman/friendly_id/master/frames ), my URLs currently look like this:
http://localhost:3000/cities/seattle/restaurants/joes-diner
Given that in my case, a city wouldn't have anything but restaurants, I'm looking for a way to remove the "restaurants" bit in the URL, so that it would look like this:
http://localhost:3000/cities/seattle/joes-diner
or if possible even
http://localhost:3000/seattle/joes-diner
What's the best way to achieve this - if it's at all advisable to do this? I can imagine that the last option might create some complications.
Upvotes: 1
Views: 842
Reputation: 358
Solution with specs and correct edit\update etc. slugs here:
http://jasoncodes.com/posts/rails-3-nested-resource-slugs#solution
Upvotes: 0
Reputation: 10744
You can find the fix to your problem in http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing#controller-namespaces-and-routing
You can use :path => ""
for this task.
Regards!
Upvotes: 3