Reputation: 6579
I'm new to Emberjs and I'm developing Nodejs /Express/ app with MongoDB and Ember. According to this blog post I added primaryKey
, serializerId
to my extended adapter.
window.Frontend.Adapter = DS.RESTAdapter.extend({
namespace: 'api',
serializer: DS.RESTSerializer.extend({
serializeId: function(id) {
return id.toString();
},
primaryKey: function(type) {
return "_id";
}
})
});
window.Frontend.Store = DS.Store.extend({
adapter: 'window.Frontend.Adapter'
});
Everything is working perfect. But namespace not working for me. The request is sent to http://localhost:3000/pages
not http://localhost:3000/api/pages
. I don't have any idea.
Other resources for related issue:
I'm using Ember 1.1.2 with Ember-Data 1.0.0.beta3. Thank you for any advice? If you need more info let me know :D
UPDATED If have similar issue go to this issue
Upvotes: 1
Views: 1457
Reputation: 33654
Things have slightly changed in Ember Data. The following code works for me using Ember 1.3 and Ember Data 1.0.0 Beta 5.
App = Ember.Application.create();
App.ApplicationSerializer = DS.RESTSerializer.extend({
primaryKey: '_id',
});
App.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: 'api'
});
Update: Looking at the latest source code, it seems primaryKey
is now a String. So you can drop serializeId
function, which by the way I don't think even exists anymore.
Upvotes: 2