title: Allow CORS in Ruby on Rails
body: <p>In my <code>config/application.rb</code> file, I have this code,</p>
  
  <pre><code>config.action_dispatch.default_headers = {
          'Access-Control-Allow-Origin' =&gt; '*',
          'Access-Control-Request-Method' =&gt; 'GET, PATCH, PUT, POST, OPTIONS, DELETE'
      }
  </code></pre>
  
  <p>But that does not allow me to send a post request to a route on my sever</p>
  
  <p>Safari gives this error:</p>
  
  <pre><code>http://localhost:3000/studentsFailed to load resource: the server responded with a status of 404 (Not Found)
  http://localhost:3000/studentsFailed to load resource: Origin http://localhost:4200 is not allowed by Access-Control-Allow-Origin.
  localhost:1XMLHttpRequest cannot load http://localhost:3000/students. Origin http://localhost:4200 is not allowed by Access-Control-Allow-Origi
  </code></pre>
  
  <p>And in my Rails server console:</p>
  
  <pre><code>Started OPTIONS "/students" for ::1 at 2015-03-28 21:00:45 -0500
  
  ActionController::RoutingError (No route matches [OPTIONS] "/students"):
  </code></pre>