You can use a "catch-all" route at the end of your routes file:
map.connect ':username', :controller => 'profiles', :action => 'show' (this is for Rails 2.3)
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
def show
if User.find_by_username(params[:username])
if @current_user == User.find_by_username(params[:username])
# @profile = @current_user.profile
# render projects#show view
else
# flash error message, because the current user tries to access other users profile (in case your app doesn't allow it)
else
# render page not found error
end
end
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.