in Rails, I have a user model with :id and :name.
If I use
match '/:id' => 'users#show'
in config/route.rb, with
http://app.com/1
I see the user, but if I use
match '/:name' => 'users#show'
don’t work, any idea ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you using generated controllers? The
showaction probably expects anidparameter (which is why it works). You need to use the correct ActiveRecord finder, such asUser.find_by_nameif you want to pass in thenameparameter.