Before answering your question, I have to say the code in your question is wrong. Please check and modify your code so more people can understand it.
For example in your code:
/* It should be App.Customer right? */
App.CustomerModel = DS.Model.extend({});
/* should be App.CustomerIndexRoute ? */
App.CustomerIndexController = Ember.Route.extend({
model: function(params) {
/* it returns a promise which resolves a customer array */
return this.store.find('customer');
}
});
App.CustomerIndexController = Ember.Controller.extend({
/*
* But for a customer array you can not get events property.
* you can only get events from a single customer.
*/
filteredEvents: function() {
return this.get('events').slice(0, 10);
}.property('events')
});
For multiple GET requests for events
No matter how you construct your route & controller code, when you iterate events for a customer, Ember Data sends a request /events/:id
for each un-fetched event. You can set coalesceFindRequests: true
in your adapter to load events in one request, like /events/ids[]=1&ids[]=2&ids[]=3
.
For multiple OPTION requests
Please check if you use proxy to delegate ajax requests to a remote server or a mock server. As I know an OPTION request will appear when your proxy can not delegate the request correctly. In this case you may see an OPTION request and a GET request at the same time. It's not an Ember Data problem.
this.store.find('someModel')
? – MilkyWayJoethis.store.find('customer')
– alvincrespofind
always sends a request. Try usingfind
in the parent level only (in the resource route) and useall
instead in the index route (or whatever route you're actually displaying data) – MilkyWayJoe