Reputation: 463
I am writing a rails 3 application and want to change an existing route that goes like:
domain.com/tapes/2
to that:
domain.com/tapename
i.e., instead of fetching the default route based on resource 'tapes' id, I want the app to match any string 'tapename' to the show page of the corresponding record.
Could you please point me to the right direction? Thank you very much for your time.
Upvotes: 1
Views: 786
Reputation: 124419
Add a new match
statement as the last route in your routes.rb
file (if you put it earlier, it'll be matched before other resources; and of course, make sure your shows
resource is listed before the match
statement):
resources :shows
match "/:id" => "tapes#show"
Upvotes: 2