title: How can I post JSON data with curl and use it in RoR?
body: <p>I am building an iOS app and it needs to post to a RoR API.</p>
  
  <p>To test the POST, I am running this command:</p>
  
  <pre><code>curl -d @/tmp/data localhost:3000/api/ratings
  </code></pre>
  
  <p>Where /tmp/data contains an array of hashes:</p>
  
  <pre><code>[    {        "uid": "gilt_162929239",        "rate": 1    }   ]
  </code></pre>
  
  <p>In Ruby, params looks like this:</p>
  
  <pre><code>[1] pry(#&lt;Api::PromotionRatingsController&gt;)&gt; params
  =&gt; {"    {        \"uid\": \"good_162929239\",        \"rate\": 1    }   "=&gt;nil,
   "format"=&gt;"json",
   "action"=&gt;"create",
   "controller"=&gt;"api/ratings"}
  </code></pre>
  
  <p>How do I get Rails to create the array of hashes for me to iterate over with each?</p>
  
  <p>Edit: I see I was missing headers.</p>
  
  <p>Adding to the curl command line:</p>
  
  <pre><code>--header "Accept: application/json" --header "Content-type: application/json"
  </code></pre>
  
  <p>Now, here are my params:</p>
  
  <pre><code>[1] pry(#&lt;Api::PromotionRatingsController&gt;)&gt; params
  =&gt; {"_json"=&gt;[{"uid"=&gt;"good_162929239", "rate"=&gt;1}],
   "format"=&gt;"json",
   "action"=&gt;"create",
   "controller"=&gt;"api/ratings",
   "promotion_rating"=&gt;{"_json"=&gt;[{"uid"=&gt;"good_162929239", "rate"=&gt;1}]}}
  </code></pre>
  
  <p>Still not right.</p>