How to turn flag "isNew" to false?


#1

Hi there,

I am looking for something a little bit tricky. Today, I am working with a model which live in session (server side) and I need to create it client side when the session is empty.
But, following the REST/CRUD philosophy I need to PUT on it to update it.

So, as newest created record, Ember Data make a post and the models root ; in conclusion, I need to turn the “IsNew” flag of the record to false to perform a PUT instead of a POST.

Any idea on the way to do that ?

Sorry for my bad english ; feel free to ask any question in case of miscomprehension.


#2

I think you’re trying to work around an issue by setting a lifecycle property which in turn will use the verb you’re after. Instead, I would recommend implementing your own adapter which extends from DS.RestAdapter and reimplement methodForRequest.

Tutorial on implementing a custom adapter: https://guides.emberjs.com/v2.7.0/models/customizing-adapters/


#3

It seem pretty good. Thank you !