I would like to be able to inject singleton Session into my Ember models. In the case of the use that I am trying to support, there are computed model properties that respond to the user profile (property of the Session object).
App = window.App = Ember.Application.create({ ready: function() { console.log('App ready'); this.register('session:current', App.Session, {singleton: true}); this.inject('session:current','store','store:main'); this.inject('controller','session','session:current'); this.inject('model','session','session:current'); } });
Injection works fine in the controller, but I'm having trouble getting it in model . Are there any limitations here? Any special methods?
-------- Additional context ---------
Here is an example of what I would like to do in my model definition:
App.Product = DS.Model.extend({ name: DS.attr("string"), company: DS.attr("string"), categories: DS.attr("raw"), description: DS.attr("string"), isConfigured: function() { return this.session.currentUser.configuredProducts.contains(this.get('id')); }.property('id') });
ken
source share