title: Why does my webpage hang when using "redirect_to" in Rails?
body: <p>I am developing my first Rails app in the Cloud9 IDE.  Whenever I try and use <code>redirect_to</code>, the webpage just hangs.  What am I doing wrong?</p>
  
  <p>I have a UsersController class:</p>
  
  <blockquote>
  <pre><code>def index
      @users = User.all
  end
  def new
      @user = User.new
  end
  def create
      @user = User.new(user_params)
      @user.save
      redirect_to users_path        
  end
  private 
  def user_params
      params.require(:user).permit(:name, :email)
  end    
  </code></pre>
  </blockquote>
  
  <p>On the index.html.erb view I have created a small form for adding users and then a list showing all users.  </p>
  
  <p>I want to create a new user and then redirect back to the index view to show the new user added to the list.  </p>
  
  <p>Here is the index.html.erb form code</p>
  
  <pre><code> &lt;%= form_for :user, url: {action: 'create'} do |u| %&gt;
  
    &lt;%= u.label :name %&gt;
    &lt;%= u.text_field :name %&gt;
  
    &lt;%= u.label :email %&gt;
    &lt;%= u.text_field :email %&gt;
  
    &lt;%= u.submit %&gt;
   &lt;% end %&gt;
  </code></pre>
  
  <p>When I hit submit on the create form, the webpage hangs.  If I reload it, then it has worked - it shows the new user has been created and added to the list.</p>
  
  <p>I'm a new to Rails so don't know if my syntax is right, but I've tried a whole different bunch of ways of using <code>redirect_to</code> - none of them work.  Help!</p>
  
  <p>For the record, my routes are:</p>
  
  <blockquote>
  <pre><code>users_index GET    /users/index(.:format)     users#index
        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
       root GET    /                          users#index
  </code></pre>
  </blockquote>