Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Rails: How do I?

I want to incorporate a feature into a site I'm designing in rails. I want to be able to assign a user his/her own url to their profile page in the form of www.mydomain.com/userprofilepage How will i need to do this? Surely I don't want to give every user a named route in routes.rb?

2 Answers

Maybe you need to override the to_param method in your User model with whatever the user sets, as this StackOverflow answer demonstrates. I'd create a new table which is linked to the User model and holds the custom URLs and the corresponding User IDs (this way it will be easier to validate uniqueness).

Thank you! I should have known there would bean easy solution.