How do I dynamically get a route's parent route's model. Say my router looks like this:
App.Router.map ->
@resource 'farms', ->
@resource 'farm', path: '/:farm_id', ->
@resource 'attachments'
@resource 'fields', ->
@resource 'field', path: '/:field_id', ->
@resource 'attachments'
If I have 2 routes: App.FieldRoute and App.AttachmentsIndexRoute, and I want to get the Field model from App.AttachmentsIndexRoute, I could do:
model: ->
@modelFor('field')
How do I do the same thing dynamically, not specifying the model's route explicitly? In other words, if I'm looking at attachments for a Farm instead, the same code should work.
(Isn't there a way in Ember to grab the parent route from a nested route?)
UPDATE:
Doesn't look like there's a clean (API) way to do this. I found some hacks using internal properties like router.currentHandlerInfos. Might have to go that route until Ember team adds a proper way of doing this.