I want to be able to have twitter like friendly urls like http://twitter.com/username. How to pull this off in rails?
I want to be able to have twitter like friendly urls like http://twitter.com/username .
Share
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.
Probably the easiest way is to have a catch-all route at the bottom of your routing table. Something like:
Then in the users controller….
I would also recommend catching a
ActiveRecord::RecordNotFoundto show a 404 page. You can put something like this inApplicationController:then define a method
not_foundto render an error page or something.