Ember数据提交POST请求而不是PUT

时间:2014-08-20 22:10:09

标签: ember.js ember-data

有人可以告诉我为什么Ember Data会提交POST请求而不是PUTS吗?

import Ember from 'ember';

export default Ember.Controller.extend({

  /**
   * Duplicates the session current user object as soon as it is available.
   * The `user` object is also made available to the template via the `.set()` call.
   */
  copyUser: function() {
    this.set('user', Ember.copy(this.get('session.currentUser'), true));
  }.observes('session.currentUser').on('init'),

  actions: {

    save: function() {
      var self = this;
      var form = this.get('user');

      this.store.find('user', form.id).then(function(user) {
        user.setProperties({
          email:       form.email,
          displayName: form.displayName,
          firstName:   form.firstName,
          lastName:    form.lastName,
        });

        // Does a POST instead of a PUT
        // user.id is set
        user.save();
        self.send('openPopover', 'users/show');
      });
    }
  }
});

0 个答案:

没有答案