Embedded records documentation


#1

I was wondering if I could get an extra pair of eyes on this JSBin:

As far as I can tell I’ve done the right thing as per the docs, but I get the error TypeError: Cannot read property 'typeKey' of undefined

Apologies if I’ve missed something obvious it’s 5.30 on a Friday :confused:


#2

I modified your jsbin : jsbin please take a look is that what you want? Embedded records with ember data lil bit tricky with real REST server, I spent few days trying to make them work but with no success and decided to side loaded them in REST adapter serializer


#3

Thank you @alekso I see what you did there!

Unfortunately the payload from our API will be like that of my original JSBin example - is it even possible to do out of the box? Or would I have to write a custom deserializer?


#4

I dont believe it will work out of the box. For me it wasnt. Did you saw this article of Transition.md ? My server API returns relationships as embedded too and I just did overwrite extract single and extractArray as described in link I mentioned above. And its kinda working :smile: . If you want to support native embedded you should implement EmbeddedRecordsMixin, but I found this not easy job because you need to download it as separate package and it works with activemodel-adapter package. As I know activemodel is Rails specific adapter, but may be I’m wrong. I suggest you to make some research because I’m also writing my first app and not emberjs expert so dont want to put you on wrong way :). It will be great if you will share your solution as well here BR Alex


#5

Ah ha,

I managed to create what I was after by using ActiveModelSerializer instead of RESTSerializer. I’m not sure why it doesn’t work with RESTSerializer


#6

Got it… changing the URLS in the above JSBin from beta to canary works.