Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Load a subclass data model into a superclass's route

$
0
0

@johnnyicon wrote:

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:

/vehicle/21/edit

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!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles