mercredi 3 février 2016

Ember active model adapter - serializer not working with camelCase-> under_score attrs

//serializsers/application.js

import { ActiveModelSerializer } from 'active-model-adapter';
//import DS from 'ember-data';
export default ActiveModelSerializer.extend({
  keyForAttribute: function(attr, method) {
   return Ember.String.underscore(attr);
 },
});

//adapters/application.js

import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
});

I tried to trace the issue. seems like "serializeIntoHash" eats up the value of attr with underscore.

profileType -> profile_type and profileId-> profile_id goes null ( The snapshot is updated with their values)

//models/user.js

import DS from 'ember-data';
const {
  attr,
  belongsTo
}=DS;
export default DS.Model.extend({
  email: attr('string'),
  profile: belongsTo('profile',{polymorphic:true , async: true}),
  mobile: attr('string'),
  password:attr('string'),
  profileId: null,
  profileType: attr('string')
});

//versions

 Ember Inspector
    1.9.4
    Ember
    1.13.12
    Ember Data
    1.13.15
    jQuery
    1.11.3
Ember Simple Auth
1.0.0




Aucun commentaire:

Enregistrer un commentaire