title: Rails 5: Post route doesn't work with root url
body: <p>I'm currently adding a survey form to my homepage. The visitor then gets suggestions based on the input. I'm sending an ajax request to deliver the suggestions to the user.</p>
  
  <p>Since the form is on my homepage, I need to create a <code>post</code> route for my <code>root url</code>.</p>
  
  <p>My ajax code:</p>
  
  <pre><code>  $.ajax({
      data: 'impressions=' + impressions,
      dataType: 'script',
      type: 'post',
      url: "/pages/home"
    });
  </code></pre>
  
  <p>When I use <code>pages/home</code> in the <code>url</code> I get the following error:</p>
  
  <pre><code>ActionController::RoutingError (No route matches [POST] "/pages/home"):
  </code></pre>
  
  <p>When I just use <code>/</code> in the <code>url</code> I get the this error:</p>
  
  <pre><code>Processing by RegistrationsController#create as JS
    Parameters: {"impressions"=&gt;"278"}
  Can't verify CSRF token authenticity.
  Completed 422 Unprocessable Entity in 3ms (ActiveRecord: 0.0ms)
  
  ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
  </code></pre>
  
  <p>It's somehow processing through the <code>RegistrationsController</code></p>
  
  <p>Those are my routes:</p>
  
  <pre><code>  root to: 'pages#home'
    # pages/home/:impressions not working
    post 'pages/home/:impressions' =&gt; 'pages#home'
  </code></pre>
  
  <p>PagesController home:</p>
  
  <pre><code>  def home
      @impressions = params[:impressions]
    end
  </code></pre>