Routing in Rails making the Username an URL:
问题 In my Rails App there is Device Model - User, and a Registry model( Each user has one registry). I wanted to change my routes so that instead of: "http://localhost:3000/registries/3" it shows: "http://localhost:3000/erinwalker" So I changed routes to match '/:name' => "registries#show" And the show action in my controller to: def show @user = current_user @user = User.find_by_name!(params[:name]) @registry = @user.registry And it works, but when I create or update the registry now first it