I tried to create a new record in a route using createRecord method and I persisted it using .save() method.
it is getting saved in db and showing record in my view component.
but I am generating id on my db. but when i check id is showing as null.
I think the model is not refreshing automatically on creating new record.
when I manually refresh page the record is showing with id
What data does your API return? It sounds like Ember isn’t able to extract the ID from the API response.
I am getting response from db with id. but it is not automatically refreshing store
I am sure you are getting a response but unless it is in the exact form ember expects then it will not automatically extract the ID and update the store. Take a look into the normalizeResponse, specifically normalizeSaveResponse which is the hook you can use after saving a record.
but when I refresh the page the record is updating with id.
So I think the problem is data store is not automatically updating on creating new record.
But it is updating on refreshing page. I found this difference using ember inspector in chrome and I had a watch on ember data in ember inspector
And I have a doubt will ember data get refreshed automatically on creating new record . ie, will it display the get response from db automatically??
were you ever able to find an answer to this? I am having the same issue, but no luck. I’ve seen alot of questions like this from several years back, which included workarounds, but none of the workarounds really worked for me. Basically, i only get back the data that i included in the “CreateRecord” part, but not the id that came from the server.
Having the same issue. @rpcollins were you ever able to solve this?
Unfortunately not. I ended up just writing an ajax call and bypassing the adapter/store for that particular call.
I have face this type of issue and solved it by simply using :
this.store.unloadAll('PARTICULAR MAODEL NAME');
Not the right way. But, It solved the problem.