when I navigate to ‘/analyses/1/dataFunctions’ my analysis model is loaded (it is show in ember inspector) but I can’t seem to access it in my data-functions/index.js route. How do I go about this? I need the analysis model to extend findAll in my data-function adapter to change the url for a rails-api nested resource.
I tried using this.store.modelFor("analysis").get("id") but it errors saying get is not a funcion.
I am lost here, any help would be greatly appreciated.
Because your ‘dataFunctions’ route doesn’t reside within your ‘analyses’ route, even though the URL is nested, it is technically not a child of the ‘analyses’ route. Therefore, modelFor() will not work if you visit the ‘dataFunctions’ route directly. However, if you first visit one of the analyses new/show/edit routes first, then navigate to dataFunctions, then it should work. You should move the ‘dataFunctions’ route to within the ‘analyses’ route, at the same level as new/show/edit.
import Ember from 'ember';
export default Ember.Route.extend({
model() {
let analysis = this.modelFor('analysis');
// ...
}
});
I tried analyses, analyses/show, analysis, show, analyses:show. Everytime it returns undefined. Ember inspector is showing the analysis loaded and I can’t access it :sadface:
@escobera did you get it working? Basically what @brian_ally said: make the datafunctions a nested route, this will make sure the parent model is loaded and then in your nested route use this.modelFor(‘route name’) to get the model.
If you are not sure about the route name, you can see it in the ember inspector.