Ember attaching a RESTAdaptor: error on <Ember.Route:ember325> / Error while loading route followed by massive dump of JavaScript-Collection of common programming errors
I’m new to Ember and getting this massive and somewhat cryptic error when moving from the Fixture Adaptor to the REST Adaptor. No other code changes were made other than commenting out my fixture data.
my code:
App = Ember.Application.create();
// App.ApplicationAdapter = DS.FixtureAdapter.extend();
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: 'http://192.168.1.193:8080',
namespace: '/serviceprovidersservice/rest'
});
App.Router.map(function() {
this.resource("service_providers", function() {
this.route("new");
this.route("edit", { path: 'edit/:id' });
});
this.resource("customers", function() {
this.route("new");
this.route("edit", { path: 'edit/:id' });
});
});
// Routes
App.ServiceProvidersIndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('ServiceProvider');
}
});
App.ServiceProvidersNewRoute = Ember.Route.extend({
model: function() {
return this.store.find('ServiceProvider');
}
});
App.ServiceProvidersEditRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('ServiceProvider', params.id);
}
});
App.CustomersIndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('Customer');
}
});
App.CustomersEditRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('Customer', params.id);
}
});
App.CustomersNewRoute = Ember.Route.extend({
model : function() {
return {
serviceproviders : this.store.find('ServiceProvider')
};
}
})
// Controllers
App.ServiceProvidersNewController = Ember.ObjectController.extend({
actions : {
create: function() {
name = this.get("name");
if (!name.trim()) { return; }
email = this.get("email");
sp = this.store.createRecord('ServiceProvider', {
name: name,
email: email
});
sp.save();
this.set('name', '');
this.set('email', '');
this.transitionToRoute("service_providers.edit", sp);
}
}
});
App.ServiceProvidersEditController = Ember.ObjectController.extend({
isEditing: false,
actions: {
edit: function() {
this.set('isEditing', true);
},
doneEditing: function() {
this.set('isEditing', false);
this.get('model').save();
}
}
});
App.CustomersEditController = Ember.ObjectController.extend({
isEditing: false,
actions: {
edit: function() {
this.set('isEditing', true);
},
doneEditing: function() {
this.set('isEditing', false);
this.get('model').save();
}
}
});
App.CustomersNewController = Ember.ObjectController.extend({
selectedServiceProvider : null,
actions : {
create: function() {
firstname = this.get("firstname");
lastname = this.get("lastname");
if (!firstname.trim()) { return; }
email = this.get("email");
serviceprovider = this.get("selectedServiceProvider");
sp = this.store.createRecord('Customer', {
firstname: firstname,
lastname: lastname,
email: email,
serviceprovider: serviceprovider
});
sp.save();
this.set('name', '');
this.set('email', '');
this.transitionToRoute("customers.edit", sp);
}
}
});
// Models
App.Customer = DS.Model.extend({
serviceprovider: DS.belongsTo('serviceProvider'),
firstname: DS.attr('string'),
lastname: DS.attr('string'),
email: DS.attr('string')
});
App.ServiceProvider = DS.Model.extend({
name: DS.attr('string'),
email: DS.attr('string'),
customers: DS.hasMany('customer', {async:true})
});
The errors:
[15:46:25.144] DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on )
trigger@file:///home/zen/ember/js/libs/ember-1.0.0.js:29641
handleError@file:///home/zen/ember/js/libs/ember-1.0.0.js:29903
invokeCallback@file:///home/zen/ember/js/libs/ember-1.0.0.js:8055
Promise.prototype.then/
Originally posted 2013-11-23 07:55:42.