@@ -104,7 +104,9 @@ const processRelationships = function(relationshipHash, jsonData, record) {
104104
105105 iterateRelations ( record , relationshipHash , ( name , kind , related , subRelations ) => {
106106 processRelationship ( name , kind , related , subRelations , ( payload ) => {
107- jsonData . relationships [ name ] = payload ;
107+ let serializer = record . store . serializerFor ( record . constructor . modelName ) ;
108+ let serializedName = serializer . keyForRelationship ( name ) ;
109+ jsonData . relationships [ serializedName ] = payload ;
108110 } ) ;
109111 } ) ;
110112 }
@@ -136,28 +138,31 @@ export default Ember.Mixin.create({
136138 serialize ( snapshot /*, options */ ) {
137139 savedRecords = [ ] ;
138140 let json = this . _super ( ...arguments ) ;
139- delete ( json . data . relationships ) ;
140- delete ( json . data . attributes ) ;
141141
142- let adapterOptions = snapshot . adapterOptions || { } ;
142+ if ( snapshot . record . get ( 'emberDataExtensions' ) !== false ) {
143+ delete ( json . data . relationships ) ;
144+ delete ( json . data . attributes ) ;
143145
144- let attributes = attributesFor ( snapshot . record ) ;
145- if ( isPresentObject ( attributes ) ) {
146- json . data . attributes = attributes ;
147- }
146+ let adapterOptions = snapshot . adapterOptions || { } ;
148147
149- if ( snapshot . record . id ) {
150- json . data . id = snapshot . record . id . toString ( ) ;
151- }
148+ let attributes = attributesFor ( snapshot . record ) ;
149+ if ( isPresentObject ( attributes ) ) {
150+ json . data . attributes = attributes ;
151+ }
152152
153- if ( adapterOptions . attributes === false ) {
154- delete ( json . data . attributes ) ;
153+ if ( snapshot . record . id ) {
154+ json . data . id = snapshot . record . id . toString ( ) ;
155+ }
156+
157+ if ( adapterOptions . attributes === false ) {
158+ delete ( json . data . attributes ) ;
159+ }
160+
161+ let relationships = relationshipsDirective ( adapterOptions . relationships ) ;
162+ processRelationships ( relationships , json . data , snapshot . record ) ;
163+ snapshot . record . set ( '__recordsJustSaved' , savedRecords ) ;
155164 }
156165
157- let relationships = relationshipsDirective ( adapterOptions . relationships ) ;
158- processRelationships ( relationships , json . data , snapshot . record ) ;
159- snapshot . record . set ( '__recordsJustSaved' , savedRecords ) ;
160- console . log ( 'serialized' , json ) ;
161166 return json ;
162167 }
163168} ) ;
0 commit comments