If you want to use usernames instead of identifiers, try friendly_id gem.
If you want to do this yourself, the easiest way is to override the to_param method in our model to return the username, and then search your controller by username.
In the model:
def to_param username end
In the controller:
def show @user = User.find_by_username(params[:id]) end
In the routes.rb file:
match '/:id' => 'profiles#show'
source share