Skip to content

Instantly share code, notes, and snippets.

@brandonhilkert
Created June 26, 2015 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonhilkert/121c1545b036f2eb3f88 to your computer and use it in GitHub Desktop.
Save brandonhilkert/121c1545b036f2eb3f88 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function() {
var app = this.modelFor('apps/show');
var adapter = this.container.lookup('adapter:application');
var url = adapter.buildURL('app', app.get('id')) + '/metrics';
adapter.ajax(url, 'GET').then(function(response) {
debugger
});
}
});
@seanpdoyle
Copy link

If you plan to stick with this approach, you'll want to change

"adapter:application" to "adapter:app" (if app is the name of the model)

@seanpdoyle
Copy link

Having said that, I think it's more idiomatic to do the following:

// app/models/app.js

export DS.Model.extend({
  metrics: DS.belongsTo('metric', { async: true }),
})
// app/routes/apps/show/index.js

export default Ember.Route.extend({
  model() {
    const app = this.modelFor('apps/show');

    return app.get('metrics');
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment