Load a subclass data model into a superclass's route

Is there a way to load a subclass data model into a superclass’s route?

As an example, I have a superclass named Vehicle and a subclass named Car.

I have route like this:


And in this instance, Vehicle #21 is a Car. Accrodingly, my API returns the following payload data:

{"car": {/* lots of data */}}

When the route vehicle.edit tries to load this data, I get the following error:

Error while processing route: vehicle.edit payload.data is null

I can work around this by changing my API so that it uses vehicle as the root node in the JSON response, but I was wondering if Ember has a way to automatically cast a subclass into a superclass (e.g., load the car JSON response into a Vehicle instance).

Thanks in advance!

Sounds like you’re using RESTSerializer? You could definitely do this yourself in the adapter or serializer layer, but I can’t think of any Ember built-in that would accomplish what you want.