I am trying to change the rails routes from /users/1 to /username. I currently set this up so it works for the actions of showing and editing. The actual issue is that when
In the User model override the to_param method to return what you want used in the URL.
to_param
class User < ActiveRecord::Base def to_param username end end
In your controller instead of using User.find(params[:id]) you now need to use User.find_by_username(params[:id])
User.find(params[:id])
User.find_by_username(params[:id])