vendredi 22 mai 2015

Uncaught Error: No model was found for 'model'

I'm building an Ember-CLI app using the following:

DEBUG: Ember                          : 1.10.0
DEBUG: Ember Data                     : 1.0.0-beta.15
DEBUG: jQuery                         : 2.1.3

Using a form, I'm trying to save changes on 2 separate models. One of the models (the user model) saves successfully, while the other (profile model) throws this error:

Uncaught Error: No model was found for 'userProfile'

Models

The two models in question are:

models/user.js
models/user/profile.js

Controller

import Ember from "ember";

export default Ember.Controller.extend({
  saved:false,
  actions: {
    save:function(){
      this.get('model.user').save();
      this.get('model.profile').save();
      this.set('saved',true);
    },
  },
});

Route

import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, {
  model: function(){
    var _this = this;
    var currentUser = this.get('session.user');

    return new Ember.RSVP.all([
      _this.store.find('user', currentUser.id),
      _this.store.find('user.profile', {UserId: currentUser.id}),
    ]).then(function(values){
      return {
        user: values[0],
        profile: values[1].get('firstObject'),
      }
    });
  },
});




Aucun commentaire:

Enregistrer un commentaire