I’m using Devise for my User model and sessions control. I’d like to use path names like “/users/my-awesome-username” rather than “/users/1” so that I don’t advertise how many users are in the database. What is the best practice for doing so when using Devise?
I’m using rails 3.1 and devise 1.4.7 if that matters.
You could either just define a
User#to_parammethod that returns the username.However, if you’d want to do some more fancy stuff, like generating unique slugs for blog posts or something like that, then there’s a Gem called Friendly Id that takes care of this for you.