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.