I have red docs on friendly_id for rails. It’s easy: you set a certain attribute to be the slug.
example.com/username
User has_one profile
Profile belongs_to User
So you see my dilemma. I have no column username in the profile model. How can I link the user model, username field so that I can do example.com/username with friendly_id?
Surely this is relatively simple.
You can use a “catch-all” route at the end of your routes file:
And in the profiles controller, method show you check if there is a user with that username, and if it belongs to the current profile
I had a similar situation for a projects model, from projects/id => /project_name.
It is a bit easier in your case because in the db you have unique usernames.
Ah, and no extra gems are involved.