Rails Route based on something different than ID
Another possibility to consider would be the friendly_id gem - https://github.com/norman/friendly_id
You need is to override to_param method in User model:
class User
def to_param
username
end
end
Then rails will use it automagically for routing. See http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-i-to_param