ember.js - How do I update Ember CLI record with rails 4 Grape API with PUT? -


i have rails 4 app setup grape api , ember cli app fronted following this tutorial built using activemodeladapter. working correctly in getting data api, i'm having issues sending post or put requests api create or edit records. found tutorial shows example, uses restadapter , different api, of how create remaining crud operations. i'm having trouble getting put or post requests have appropriate form, think. here's error i'm getting:

    put http://localhost:3000/api/v1/contacts/3 400 (bad request)jquery.ajaxtransport.send @ jquery.js:9665jquery.extend.ajax @ jquery.js:9216ember$data$lib$system$adapter$$adapter.extend.ajax @ inflector.js:30initializepromise @ ember.debug.js:45487promise @ ember.debug.js:47115ember$data$lib$system$adapter$$adapter.extend.ajax @ inflector.js:30ember$data$lib$system$adapter$$adapter.extend.updaterecord @ rest-adapter.js:687ember$data$lib$system$store$$_commit @ debug-adapter.js:109(anonymous function) @ store.js:1627foreach @ ember.debug.js:12012ember$data$lib$system$store$$service.extend.flushpendingsave @ store.js:1611queue.invoke @ ember.debug.js:879queue.flush @ ember.debug.js:944deferredactionqueues.flush @ ember.debug.js:749backburner.end @ ember.debug.js:174backburner.run @ ember.debug.js:229run @ ember.debug.js:15864actionhelper.registeraction.actionmanager.default.registeredactions.(anonymous function).handler @ ember.debug.js:18409(anonymous function) @ ember.debug.js:36725jquery.event.dispatch @ jquery.js:4671jquery.event.add.elemdata.handle @ jquery.js:4339 ember.debug.js:26511 error: bad request     @ ember$data$lib$system$adapter$$adapter.extend.ajaxerror (inflector.js:6)     @ superfunction [as _super] (ember.debug.js:13812)     @ ember$data$lib$adapters$rest$adapter$$default.extend.ajaxerror (json-serializer.js:75)     @ apply (ember.debug.js:17855)     @ superwrapper [as ajaxerror] (ember.debug.js:17437)     @ ember$data$lib$system$adapter$$adapter.extend.ajax.ember.rsvp.promise.hash.error (inflector.js:30)     @ jquery.callbacks.fire (jquery.js:3149)     @ object.jquery.callbacks.self.firewith [as rejectwith] (jquery.js:3261)     @ done (jquery.js:9317)     @ xmlhttprequest.jquery.ajaxtransport.send.callback (jquery.js:9719) 

here's adapter.js:

import ds 'ember-data'; import env "../config/environment";  export default ds.activemodeladapter.extend({     namespace: 'api/v1',     host: env.host }); 

here's router.js:

    import ember 'ember';     import config './config/environment';      var router = ember.router.extend({       location: config.locationtype     });       router.map(function() {       this.route('dashboard', function() {           this.resource('contacts', function() {               this.route('new');               this.route('show', { path: '/:contact_id' });               this.route('edit', {path: '/:contact_id/edit'});             });         });     });  export default router; 

here's contacts/edit.js route:

import ember 'ember';  export default ember.route.extend({     model: function(params) {return this.store.find('contact', params.contact_id);},     actions: {         save: function() {               var self = this;             self.controller.get('model').save().then(                 function() {                     self.transitionto('contacts.index');                 });         },         delete: function() {             var self = this;             var model = self.controller.get('model');              model.destroyrecord().then(                 function() {                     self.transitionto('contacts.index');                 }, function (error) {                     ember.logger.debug(error);                 });         }     } }); 

i believe problem somewhere between edit router , adapter... i'm having trouble identifying problem here.

update 1: rails log outputs: started put "/api/v1/contacts/3" ::1 @ 2015-07-13 10:47:04 -0800

any help/ideas appreciated!!

this sounds more backend issue ember issue. check backend responding requests (either via logs, or testing postman, curl, etc)


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -