title: How do I prevent URL in browser bar from changing when a user is returned to a form to correct errors?
body: <p>I 'm using Rails 5.  I have a page where a user can update their profile and if something goes wrong, they are returned to the page</p>
  
  <pre><code>  def update
      @user = current_user
      if @user.update_attributes(user_params)
        …
        redirect_to url_for(:controller =&gt; ‘main’, :action =&gt; 'index') and return
      end
  
      render 'edit'
    end
  </code></pre>
  
  <p>The problem is, when they are returned to the original page, the URL in the browser bar reads, “<a href="http://localhost:3000/users/51" rel="noreferrer">http://localhost:3000/users/51</a>”, which is not the original URL they were visiting (that was “<a href="http://localhost:3000/users/edit" rel="noreferrer">http://localhost:3000/users/edit</a>”).  How can I get the URL to remain the same as what it was?</p>
  
  <p><b>Edit:</b> This is what is produced when I run rake routes</p>
  
  <pre><code>           edit_users GET    /users/edit(.:format)                      users#edit
                  users GET    /users(.:format)                           users#index
                        POST   /users(.:format)                           users#create
               new_user GET    /users/new(.:format)                       users#new
              edit_user GET    /users/:id/edit(.:format)                  users#edit
                   user GET    /users/:id(.:format)                       users#show
                        PATCH  /users/:id(.:format)                       users#update
                        PUT    /users/:id(.:format)                       users#update
                        DELETE /users/:id(.:format)                       users#destroy
  </code></pre>