Question

I am trying to add an ember app to an existing (large) rails app. If it works out, I would like to use ember for many new areas of the app, but I'm starting small.

Essentially, the user is on a rails Students index page, clicks on one of many links to manage a student's IEPs, and then the modal box containing the ember app is shown. When we first spiked this back in May, we did this as follows:

showDialog: (url) ->
  studentId = ...
  $('#emberDialog').dialog
    open: ->
      student = App.Student.find(studentId)
      App.Router.router.transitionTo('studentIeps.index', student)

Now that we are picking this up again, I'm finding that in the bump from Ember V1.0.0-rc.5-80-gf54e8ef to V 1.1.3+pre.e0ffbf84 and Ember-data from V0.13-30 to V1.1.0-beta.3-4 the Model.find methods have been removed.

Is there a supported way to do this any longer? I'm trying to build an instance of a model external to the ember app, and then use that to set the ember app's current route. Halp?

Was it helpful?

Solution

You can fetch an instance of the application controller from the container, from there you can do everything you were doing before. The controllers have an instance of the store on them, which is how you get models now. You'll probably have some other issues with your data/adapters, see the transition document: https://github.com/emberjs/data/blob/master/TRANSITION.md

showDialog: (url) ->
  studentId = ...
  $('#emberDialog').dialog
    open: ->
      appController = App.__container__.lookup('controller:application')
      store = appController.get('store')
      student = store.find('student', studentId)
      appController.transitionToRoute('studentIeps.index', student)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top