title: AJAX Request POST data to rails controller gives 404
body: <p>I want to post data to a rails controller via an AJAX request</p>
  
  <p>My route: <code>get "pki_login/authenticate" =&gt; "pki_logins#authenticate"</code></p>
  
  <p>The JS:</p>
  
  <pre><code>$.ajax({
      type: 'POST',
      url: '/pki_login/authenticate',
      dataType: 'json',
      contentType: "application/json; charset=utf-8",
      success: function(data) {
          alert("Successful");
        },
      data: passcode
  });
  </code></pre>
  
  <p>then inside <code>pki_logins_controller.rb</code> i have:</p>
  
  <pre><code>def authenticate
    puts params[:passcode]
  end
  </code></pre>
  
  <p>the <code>authenticate.html.erb</code> file just contains a <code>h3</code> tag.</p>
  
  <p>I can visit /pki_login/authenticate and it works, but when accessing via AJAX I get a 404 so I don't even know if the POST works either</p>