Reputation: 1321
If ember_model.js included the following code works fine: (btw Ember Model : 0.0.11 isnt part of ember.js? why do i have to include in an MVC framework the model in a separeted js file? )
App = Ember.Application.create();
App.IndexRoute = Ember.Route.extend({
model: function() {
return App.User.find();
}
});
App.User = Ember.Model.extend({
username: Ember.attr()
});
App.User.adapter = Ember.RESTAdapter.create();
App.User.url = "/sf2/web/app_dev.php/api/users";
App.User.collectionKey = "users";
now i want to use ember_data.js (DEBUG: Ember Data : 1.0.0-beta.7.f87cba88). There is no error in the console, but as i see the networking, there is no call to the api, and the page stays blank.
App = Ember.Application.create();
App.Store = DS.Store.extend({
adapter: DS.RESTAdapter.create({
url: '/sf2/web/app_dev.php/api'
})
});
App.User = DS.Model.extend({
username: DS.attr('string')
});
App.UserRoute = Ember.Route.extend({
model: function() {
return App.User.find();
}
});
Upvotes: 1
Views: 48
Reputation: 47367
Ember can be used without Ember Model and Ember Data. Ember Model and Ember Data are data persistence libraries that can be used with Ember. Ember Model was created by Erik Bryn, and not under active development. Ember Data was created by the Ember core team and is under active development.
You're essentially using Ember Data incorrectly in your second example. You should read this transition document. https://github.com/emberjs/data/blob/master/TRANSITION.md Additionally here's a small example using Ember Data.
The main concept for Ember Data is defining an adapter, a model, then using the store to find records.
App.ApplicationAdapter = DS.RESTAdapter;
App.User = DS.Model.extend({
firstName: DS.attr()
});
this.get('store').find('user');
http://emberjs.jsbin.com/OxIDiVU/269/edit
Upvotes: 1