DI/register/inject issues and questions


Our app makes heavy use of register/inject to loosely couple our controllers from our domain model and services. With the release of RC2, our app was completely broken due to the changes in container lookup. We were injecting non-controller objects using inject, such as

App.inject("controller:photos.index", "configuration", "configuration:main");


App.register("service:remote_api", App.RemoteApi);
App.inject("service:remote_api", "remoteConnection", "service:remote_connection");

With RC2, both examples broke. The container name for our PhotosIndexController changed to controller:photosIndex. RemoteConnection was registered as service:remote_connection but lookup normalized the string to service:remoteConnection, leading to the object not being found. This brings up a few questions:

Question 1: Is this simply a bug or the intended behavior? It seems like normalizing the arguments to inject and register in addition to lookup would have avoided the problem completely, though I’ve not verified this.

Question 2: What are the intended naming conventions for use with the container? Is the official container name for controllers now camel-cased, or is that simply a by-product of normalization combining with a bug? I thought I’d seen examples of underscored names, but in hindsight that may have been due to looking at non-compound names through Ruby-biased eyes.

Question 3: Since the objects I’m injecting into my controller are not other controllers, I’m not using needs here. Am I interpreting the documentation correctly, or would there have been a better approach to injecting helper objects into my controller?