Reputation: 542
I need to make a Ember Resource to send its query using one of values in its schema.
Let's say I've defined this resource:
App.SomeModule = Ember.Resource.define(
{
url: './api/some',
schema:
{
id: Number,
fodder: Number,
whatever: Number,
units:
{
type: Ember.ResourceCollection,
itemType: 'App.OtherModule',
url: './api/other/%@'
}
}
});
When this resource need to load its 'units', it will automatically send a query using the url "api/other/(id). However I need to make it use other value such as (fodder) or (whatever), not id. I think (%@) need to be replaced but how?
Upvotes: 2
Views: 917
Reputation: 68
You probably want to define url
as a function instead:
units: {
url: function() {
// your custom code here:
return '/api/other/%@'.fmt(this.get('fodder'));
}
}
Upvotes: 2