Last active
January 1, 2016 03:38
-
-
Save superlou/8086495 to your computer and use it in GitHub Desktop.
Inject currentUser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.Application.initializer({ | |
name: "currentUser", | |
initialize: function(container, application) { | |
container.register('session:main', OurMemories.SessionController); | |
application.inject('session:main', 'store', 'store:main'); | |
application.inject('controller', 'session', 'session:main'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OurMemories.SessionController = Ember.Object.extend({ | |
currentUser: null, | |
init: function() { | |
currentUserMeta = $('meta[name=current_user]').attr('content'); | |
currentUserId = $.parseJSON(currentUserMeta).id; | |
currentUser = this.store.find('user', currentUserId); | |
this.set('currentUser', currentUser); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment