Ember-data update failed


#1

Hello, I use JSONAPIAdapter for my backend rails api.

read and delete are work well.

but create, update is failed.

my json data

{
  data: [
  {
     id: "21",
     type: "libraries",
     attributes: {
       name: "O'Connell-Lynch",
       address: "7883 Lind Haven",
       phone: "386.515.7236",
      created-at: "2016-04-21T10:19:28.930Z",
      updated-at: "2016-04-21T10:19:28.930Z"
  },
  relationships: {
    books: {
      data: [ ]
    }
  }
 }
 ]
 }

when I update, fail with this messages.

jquery.js:9203 PATCH http://localhost:4200/libraries/21 400 (Bad Request)send @ jquery.js:9203jQuery.extend.ajax @ jquery.js:8684_ajaxRequest @ rest.js:818(anonymous function) @ rest.js:808initializePromise @ ember.debug.js:53868Promise @ ember.debug.js:55720ajax @ rest.js:778updateRecord @ json-api.js:121_commit @ store.js:1879(anonymous function) @ store.js:1161flushPendingSave @ store.js:1144Queue.invoke @ ember.debug.js:333Queue.flush @ ember.debug.js:397DeferredActionQueues.flush @ ember.debug.js:205Backburner.end @ ember.debug.js:560Backburner.run @ ember.debug.js:682run @ ember.debug.js:21144actions.push.handler @ ember.debug.js:29632(anonymous function) @ ember.debug.js:44717jQuery.event.dispatch @ jquery.js:4737elemData.handle @ jquery.js:4549
2016-04-21 12:25:18.987 ember.debug.js:32101 Error: Ember Data Request PATCH /libraries/21 returned a 400
Payload (Empty Content-Type)
[object Object]
    at new Error (native)
    at Error.EmberError (http://localhost:4200/assets/vendor.js:26684:21)
    at Error.AdapterError (http://localhost:4200/assets/vendor.js:70524:16)
    at handleResponse (http://localhost:4200/assets/vendor.js:81978:14)
    at hash.error (http://localhost:4200/assets/vendor.js:82059:29)
    at fire (http://localhost:4200/assets/vendor.js:3447:31)
    at Object.self.fireWith [as rejectWith] (http://localhost:4200/assets/vendor.js:3577:7)
    at done (http://localhost:4200/assets/vendor.js:9047:14)
    at XMLHttpRequest.<anonymous> (http://localhost:4200/assets/vendor.js:9411:9)

How can I update database using ember-data?

additionally, below my rails console error messages

Started PATCH "/libraries/21" for 127.0.0.1 at 2016-04-21 12:25:18 +0200
Processing by LibrariesController#update as JSON
  Parameters: {"data"=>{"id"=>"21", "attributes"=>{"name"=>"Hello", "address"=>"7883 Lind Haven", "phone"=>"386.515.7236", "created-at"=>"2016-04-21T10:19:28.930Z", "updated-at"=>"2016-04-21T10:19:28.930Z"}, "type"=>"libraries"}, "id"=>"21", "library"=>{}}
  Library Load (0.1ms)  SELECT  "libraries".* FROM "libraries" WHERE "libraries"."id" = ? LIMIT ?  [["id", 21], ["LIMIT", 1]]
Completed 400 Bad Request in 2ms (ActiveRecord: 0.1ms)



ActionController::ParameterMissing (param is missing or the value is empty: library):

app/controllers/libraries_controller.rb:49:in `library_params'
app/controllers/libraries_controller.rb:29:in `update'