@@ -104,7 +104,9 @@ const processRelationships = function(relationshipHash, jsonData, record) {
104
104
105
105
iterateRelations ( record , relationshipHash , ( name , kind , related , subRelations ) => {
106
106
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 ;
108
110
} ) ;
109
111
} ) ;
110
112
}
@@ -136,28 +138,31 @@ export default Ember.Mixin.create({
136
138
serialize ( snapshot /*, options */ ) {
137
139
savedRecords = [ ] ;
138
140
let json = this . _super ( ...arguments ) ;
139
- delete ( json . data . relationships ) ;
140
- delete ( json . data . attributes ) ;
141
141
142
- let adapterOptions = snapshot . adapterOptions || { } ;
142
+ if ( snapshot . record . get ( 'emberDataExtensions' ) !== false ) {
143
+ delete ( json . data . relationships ) ;
144
+ delete ( json . data . attributes ) ;
143
145
144
- let attributes = attributesFor ( snapshot . record ) ;
145
- if ( isPresentObject ( attributes ) ) {
146
- json . data . attributes = attributes ;
147
- }
146
+ let adapterOptions = snapshot . adapterOptions || { } ;
148
147
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
+ }
152
152
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 ) ;
155
164
}
156
165
157
- let relationships = relationshipsDirective ( adapterOptions . relationships ) ;
158
- processRelationships ( relationships , json . data , snapshot . record ) ;
159
- snapshot . record . set ( '__recordsJustSaved' , savedRecords ) ;
160
- console . log ( 'serialized' , json ) ;
161
166
return json ;
162
167
}
163
168
} ) ;
0 commit comments