samedi 23 février 2019

Nested back-end resources in Ember

This question may be duplicative, but I haven't quite been able to find the answer.

I have a Rails API serving a URI like this:

/locations/1/visits

In Ember I have a route like this:

Router.map(function() {
  this.route('location', { path: '/locations/:location_id' }, function() {
    this.route('visits' , { path: 'visits' });
 });
});

..and a model like this:

export default DS.Model.extend({
  name:           DS.attr(),
  visits:         DS.hasMany('visit', { nested: true }),
});

When I hit /locations/1/visits in the browser, I expect Ember to likewise hit /locations/1/visits on the backend. Instead, it attempts /locations/1 (without visits).

Any ideas how to convince Ember to properly nest the association?

Thanks!




Aucun commentaire:

Enregistrer un commentaire