Having an interesting issue with redirects. On my user update page (at /username/edit), users can update their name, email and username. Once the update is complete, if the user updates their username, the path that they are redirected (in this case, its edit_user_path causes an error:
Cannot redirect to nil!
My Users controller looks like this:
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
find_user is a method to find @user.
Essentially, how do I force the routes to update once this update happens?
Perhaps try: