title: Rails 4 Authenticity Token
body: <p>I was working on a new Rails 4 app (on Ruby 2.0.0-p0) when I ran into some authenticity token problems.</p>
  
  <p>While writing a controller that responds to json (using the <code>respond_to</code> class method), I got to the <code>create</code> action I started getting <code>ActionController::InvalidAuthenticityToken</code> exceptions when I tried to create a record using <code>curl</code>.</p>
  
  <p>I made sure I set <code>-H "Content-Type: application/json"</code> and I set the data with <code>-d "&lt;my data here&gt;"</code> but still no luck.</p>
  
  <p>I tried writing the same controller using Rails 3.2 (on Ruby 1.9.3) and I got no authenticity token problems whatsoever. I searched around and I saw that there were some changes with authenticity tokens in Rails 4. From what I understand, they are no longer automatically inserted in forms anymore? I suppose this is somehow affecting non-HTML content types.</p>
  
  <p>Is there any way to get around this without having to request a HTML form, snatching the authenticity token, then making another request with that token? Or am I completely missing something that's completely obvious?</p>
  
  <p><strong>Edit:</strong> I just tried creating a new record in a new Rails 4 app using a scaffold without changing anything and I'm running into the same problem so I guess it's not something I did.</p>