emberjs/ember.js — pull request #2703 by lukemelia (2013-05-21 05:13:56+00:00)
Title: BREAKING: Move setting controller's `model` into setupController

This commit reverses an earlier change (43354a98). After living with
this in multiple applications, we found that it was problematic that
the `model` property is set in a place that is not easy to override.
One side effect is that when not intended, this property change can
result in observers firing at unintended times.

In addition, this change makes `setupController` consistent with
`model` and `renderTemplate` in that it has a sane default behavior
that is usually what you want but can be overridden.

This commit also introduces a lookupController hook, which can be
used to specify the controller used for a route.

Thanks to @tchak for prompting this thinking in #2044

This brings the behavior of `setupController` in line with with what is
currently documented, too.

### For the rc4 blog post

If this is merged, it is something that should be included in the RC4
blog post. Perhaps something like:

A Route's `setupController` hook previously was a no-op and the route
independently took responsibility for setting the `model`
property of the controller. This has been moved into `setupController`.
If you are overriding `setupController`, you likely don't need this. If your
intention is to extend the default behavior, you now need to call `this._super`
or set the controller's `model` property yourself.

### Ideas for the future

In the future, it would be good to rename `model` to `lookupModel` to
be consistent with the verb names of the rest of the hooks. There is some
discussion of this at #2067.

The awkwardness of this is evident by the fact a Route has a `this.controller`
and `this.currentModel` properties, along with a `this.model` method. It would
be clearer if hooks were verbs and properties were nouns.

That can be addressed in a separate PR, but we wanted to mention it as
context for discussion on this change.

Kris Selden / Luke Melia