Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOsgaldor Storm
1,119 PointsRails: 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
Unsubscribed User
4,776 PointsMaybe 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).
Osgaldor Storm
1,119 PointsThank you! I should have known there would bean easy solution.