I have a model object called ‘Problem’ and I want to be able to call its the ‘show’ action using the URL /problems/PROBLEM_NAME.
I think the way to go about this is to change it so the primary_key is no longer the default integer id, instead I want it to be a string of letters.
I have tried to rails g model problem problem_name:primary_key problem_text:text
but I get the obvious error about having multiple primary keys.
Any ideas?
I guess in your routes you have:
Before the line with
resources :problems, in your routes.rb file add thisAfter you added the new show route, in your problems controller, in the show action, instead of doing
you use now
Doing it this way, you don’t have to modify your database