I'm pretty new to ember and have been somewhat thrown in at the deep end with it so there's a good chance I'm missing something that should be incredibly obvious here.
Anyway, my rails application has defined a route as /api/1/publications/:publication_id/catalogs
. This is working fine.
However, I cannot for the life of me get Ember to use this route, everything I try either results in a request to /api/1/catalogs
- or no request at all.
My router.js file has:
Router.map(function() {
this.route('publication', { path: '/publication/:publication_id' }, function() {
this.route('catalogs', { path: '/publication/:publication_id/catalogs' });
});
});
My publications model has
catalogs: DS.hasMany('catalog'),
My catalog model has
publication: DS.belongsTo('publication')
And, amongst a few others lost to undo's, I have tried the following methods of querying this data in my route .js file
model() {
this.modelFor('publication.name')
var output = {
model: this.modelFor("publication")
};
let publication = this.modelFor('publication');
output.catalogs = publication.get('catalogs');
return RSVP.hash(output);
},
...
output.catalogs = output.model.get('/api/ember/1/publications/' + output.model.id + '/catalogs');
...
var output = {
model: this.modelFor("publication"),
catalogs: model.catalogs,
...
this.get('store').findAll('catalog', {'publication_id': output.model.id, reload: true});
Could someone please give me a pointer to what I'm doing wrong / not doing please?
Aucun commentaire:
Enregistrer un commentaire