I have a EmberJS project with two Model, they both seams to use different serializers.
By debugging inside EmberJS Data i’ve seen that for the first Model the class of Serializer is “DS.JSONAPISerializer” and for the other “DS.JSONSerializer”. I would like they both use the same.
I didn’t override any serializers and their respective adapters are empty and extend the same adapter (GeneralAdapter).
The only difference is that ModelA objects are pushed to Ember from the server using a request and the adapter (using the same adapter as ModelB) whereas ModelB is only pushing from store.pushPayload from a controller (without using the adapter).
Is it a feature or a bug or I totally miss understanding something?
JSONSerializer is a subclass of JSONAPISerializer - so technically both are used - are you sure this isn’t what you’re seeing?
Is there a reason you’re using a general adapter and empty subclasses for individual models instead of just setting ApplicationAdapter once?
Yes JSONSerializer is a subclass of JSONAPISerializer but they both have different
extractAttributes function. The JSONAPISerializer one requires
resourceHash.attributes but not JSONSerializer.
No there is no reason why I’m not using an ApplicationAdapter! Thanks for the tip, I will do it.
But it seams that it makes a difference between having a general adapter and empty subclasses vs. having an ApplicationAdapter. By the first case the default serializer is the JSONAPISerializer and in the second it’s JSONSerializer. So I’m getting an error that the serializer does not implements pushPayload…
Now I’m using
defaultSerializer to use the rest one.
That seems pretty weird - in both cases, if you have defined any adapter / serializer for your model, either using application adapter / serializer or making an individual class for that model extending something else, that should be used by rest operations and by pushPayload. If that’s not the case, it sounds like a bug to me!