title: Posting JSON data to rails controller?
body: <p>I'm having some problems posting JSON data to my rails controller and getting the fields from my JSON data to map onto the paremeters to create my entity.</p>
  
  <p>Here's what the action looks like:</p>
  
  <pre><code>def create
    @trip = Trip.new(params[:trip])
    if @trip.save
      respond_to do |format|
        format.json{render :json =&gt; @trip, :status =&gt; :created, :location =&gt; @trip }
      end
    end
  end
  </code></pre>
  
  <p>And here's the output from the web server:</p>
  
  <pre><code>Started POST "/trips.json" for 127.0.0.1 at Sat Sep 03 12:37:41 -0400 2011
    Processing by TripsController#create as JSON
    Parameters: {"title"=&gt;"Charlie"}
    AREL (0.5ms)  INSERT INTO "trips" ("created_at", "updated_at", "title") VALUES ('2011-09-03 16:37:41.945743', '2011-09-03 16:37:41.945743', NULL)
  Completed 201 Created in 15ms (Views: 3.5ms | ActiveRecord: 0.5ms)
  </code></pre>
  
  <p>As you can see it's inserting NULL into the title field, I was expecting it to map it on from the JSON data?</p>
  
  <p>Here's the HTTP request:</p>
  
  <pre><code>Host    localhost:3000
  User-Agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.1) Gecko/20100101 Firefox/6.0.1
  Accept  */*
  Accept-Language en-us,en;q=0.5
  Accept-Encoding gzip, deflate
  Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Connection  keep-alive
  Content-Type    application/json; charset=UTF-8
  X-Requested-With    XMLHttpRequest
  Referer http://localhost:3000/trips/new
  Content-Length  19
  Cookie  _tripplanner_session=BAh7ByIQX2NzcmZfdG9rZW4iMWJCVDc0YWNIeHROcmw5VC9ZVEhMdFNlR0dtTWtSVytCL0dwTi9yam1CUUU9Ig9zZXNzaW9uX2lkIiU1NzhlMDAwNmM2N2RkMTE1YTA3M2ZmMzA4NDQ0M2NmOQ%3D%3D--1c2f1fc1d7c1bd147fa1cf9cff47e77c050f51be
  Pragma  no-cache
  Cache-Control   no-cache
  </code></pre>