title: Redirecting to a new path after user updates their profile
body: <p>Having an interesting issue with redirects. On my user update page (at /username/edit), users can update their name, email and <strong>username</strong>. Once the update is complete, if the user updates their username, the path that they are redirected (in this case, its <code>edit_user_path</code> causes an error:</p>
  
  <pre><code>Cannot redirect to nil!
  </code></pre>
  
  <p>My Users controller looks like this:</p>
  
  <pre><code>def update
      find_user
  
      if @user.update_attributes(params[:user])
          sign_in @user
          flash[:success] = "User updated"
          redirect_to edit_user_path
      else
          flash[:notice] = "There was an error updating this user:"
          redirect_to edit_user_path
      end
  end
  </code></pre>
  
  <p><code>find_user</code> is a method to find <code>@user</code>.</p>
  
  <p>Essentially, how do I force the routes to update once this update happens?</p>