I’m having some trouble setting something up that I feel should be easy, but I think I’m missing something.
What I have:
- My ember app is only available if the user is logged in (Rails app)
- Active model serializers can dump model data onto the HTML page in the proper form for Ember-data
- I am loading the current user’s personal data (name/email) via an initializer in the ember-app. Looks like this:
Ember.Application.initializer name: 'currentUser' initialize: (container) -> store = container.lookup('store:main') preloadJSON = JSON.parse $('meta[name="current-user"]').attr('content') if preloadJSON loadedObj = store.push('currentUser', currentUser) user = store.find('user', loadedObj.id) controller = container.lookup('controller:currentUser').set('content', user) container.typeInjection('controller', 'currentUser', 'controller:currentUser')
What I’d like to accomplish:
- Have some models scoped specifically to this user (i.e. the user has_one questionnaire) also be preloaded into the store, so that in my ember code I can call
currentUser.questionnairestraight off the bat without a call to the server.
I’m not quite sure how to get this going. Any help would be greatly appreciated!