Uncaught TypeError: Object user has no method '_create'


#1

I’m receiving this message when attempting to save a new record. I recreated the walkthrough on SmashingMag’s website. I am using ember data v0.14. Looking at the commits it seems two others are having the same issue (possibly related to RESTAdapter). Could anyone provide an answer why?

	App = Ember.Application.create({});
App.Store = DS.Store.extend();

App.User = DS.Model.extend({
	first_name: DS.attr('string'),
	last_name: DS.attr('string'),
	email: DS.attr('string'),
	password: DS.attr('string'),
	created_at: DS.attr('string'),
	updated_at: DS.attr('string'),

	fullName: function() {
		return this.get('first_name') + ' ' + this.get('last_name');
	}.property('first_name','last_name')
});

App.Router.map(function(){
	this.resource('users',function(){
		this.resource('user', {path: '/:user_id'}, function(){
			this.route('edit');
		});
		this.route('create');
	});
});

App.IndexRoute = Ember.Route.extend({
	redirect: function() {
		this.transitionTo('users');
	}
});

App.UsersRoute = Ember.Route.extend({
	model: function() {
		return this.store.find('user');
	}
});

App.UserRoute = Ember.Route.extend({
	model: function(params) {
		return this.store.find('user', params.user_id);
	}
});

App.UserEditRoute = Ember.Route.extend({
	model: function() {
		return this.modelFor('user'); // get the same model as the UserRoute
	}
});

App.UsersCreateRoute = Ember.Route.extend({
	model: function(){
        // the model for this route is a new empty Ember.Object
        return Em.Object.create({});
    },
    
    // in this case (the create route) we can re-use the user/edit template
    // associated with the usersCreateController
    renderTemplate: function(){
        this.render('user.edit', {
            controller: 'usersCreate'
        });
    }
});

App.UsersController = Ember.ArrayController.extend({
	sortProperties: ['first_name'],
	sortAscending: true,
	usersCount: function() {
		return this.get('model.length');
	}.property('@each')
});

App.UserController = Ember.ObjectController.extend({
	deleteMode: false,

	actions: {
		edit: function() {
			// we need transitionToRoute because we are in a controller, otherwise it's transitionTo when in a route
			this.transitionToRoute('user.edit');
		},
		delete: function() {
			this.toggleProperty('deleteMode');
		},
		cancelDelete: function() {
			this.set('deleteMode',false);
		},
		confirmDelete: function() {
			this.get('model').deleteRecord();
			this.get('model').save();
			this.transitionToRoute('users');
			this.set('deleteMode',false);
		}
	}
});

App.UserEditController = Ember.ObjectController.extend({
	actions: {
		save: function() {
			var user = this.get('model');
			user.save();
			this.transitionToRoute('user',user);
		}
	}
});

App.UsersCreateController = Ember.ObjectController.extend({
	needs: ['user'],

	actions: {
		save: function () {
            // just before saving, we set the creationDate
            this.get('model').set('creationDate', new Date());
            // create a new user and save it
            var newUser = this.store.createRecord('user', this.get('model'));
            newUser.save();

            // redirects to the user itself
            this.transitionToRoute('user', newUser);
        }
	}
});