当它要放在灰烬数据更新POST放在、灰烬、它要、数据

2023-09-11 01:21:41 作者:心有余悸

我工作的一个Ember.js应用程序。我有一个更新功能,ObjectController的一部分。

函数要救我的更新模型,但是当我打电话保存(); 发送POST请求不是一个PUT请求。 (经过测试,在Chrome浏览器。)

为什么会发生呢?我怎样才能确保一个PUT请求被发送更新?

下面是我的code:

 顾客= this.get(模式);
customer.set(名称,新名字);
customer.save();
 

有关额外的参考,当我登录了dirtyType与的console.log(customer.get('dirtyType')); 它说:更新

任何帮助非常AP preciated!

更新

我已经调整样本code以上,以使其更清晰,我不是创建一个新的模型,并想要使用PUT。我有一个现成的模式,我需要更新。

解决方案 魔兽世界8.0灰烬骑士团军需官在哪 魔兽世界8.0灰烬骑士团军需官位置介绍

感谢您对您的帮助球员,但我发现这个问题,这是可笑的愚蠢。

我一直在使用了新的标志is_new,并已被添加到模型已经并覆盖isNew属性。该API

造成灰烬(和我)变得非常混乱。

我已经调整了API,一切都在世界上的好!

I'm working on an Ember.js app. I have an update function, part of an ObjectController.

The function should save my updated model, however when I call save(); it sends a POST request not a PUT request. (Tested in Chrome.)

Why would that happen? How can I make sure a PUT request is sent for updates?

Here is my code:

customer = this.get('model');
customer.set('name', 'New name');
customer.save();

For extra reference, when I log the "dirtyType" with console.log( customer.get('dirtyType') ); it says "updated".

Any help very much appreciated!

UPDATE

I've adjusted the sample code above to make it clearer, I am NOT creating a new model and wanting to use PUT. I have an existing model that I need to update.

解决方案

Thank you for all of your help guys, however I have found the issue and it is ridiculously silly.

The API I have been using had a new flag "is_new" and that had been added to the model and was overwriting the "isNew" property.

Causing Ember (and me) to get very confused.

I've tweaked the API and all is good in the world!