Ember router and controller logic

Viewed 1549

I am curious to know just what logic lies in which layer with respect to the new ember routing and controllers:

If we take the route below as an example:

step1: Ember.Route.extend
  route: '/step1'
    connectOutlets: (router, event) ->
      exercise = WZ.Exercise.createRecord()
      router.get('exercisesNewStep1Controller').set 'groups', WZ.store.find(WZ.Group)
      router.get('exercisesNewController').connectOutlet 'step', 'exercisesNewStep1', exercise

My ExercisesNewStep1Controller is currently logicless:

WZ.ExercisesNewStep1Controller = Em.Controller.extend()

The recommended advice seems to be to have the route just take care of assigning the correct outlet to the correct controller with any other logic in the controller.

Should I refactor my controller to something like this:

WZ.ExercisesNewStep1Controller = Em.Controller.extend
  createGroup: ->
    @set 'groups', WZ.store.find(WZ.Group)

This is a very simple example but I think the logic holds.

I am a bit confused what lies where with all the layers. I think there is a small amount of overhead by having to create all these xxxController, xxxView files and coupling between them.

I love ember but I just want to raise this point.

3 Answers
Related