简体   繁体   中英

Ember: Deserialize outgoing data key

I have an address model with a street2 attribute.

export default DS.Model.extend({ street2: DS.attr('string'); )};

When updating an address record - address.save(); - it doesn't decamelize the street2 key into street_2 . This results in it getting sanitized on the backend. How and where do I tell ember to send updates to an address record with street_2 instead of street2 . Would this be in the adapter? Thanks in advance!!

I configured the street2 to street_2 mapping by adding this to the serializers/address.js

```

import DS from 'ember-data';

export default DS.ActiveModelSerializer.extend({
  attrs: {
    street2: {key: 'street_2'}
  }
});

```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM