Assuming the following models:
App.User = DS.Model.extend(
email: DS.attr('string')
session_users: DS.hasMany('sessionUser')
)
App.SessionUser = DS.Model.extend(
user: DS.belongsTo('user')
state: DS.attr('string')
session: DS.belongsTo('session')
)
App.Session = DS.Model.extend(
title: DS.attr('string')
session_users: DS.hasMany('sessionUser')
)
The route session_route.js.coffee:
App.SessionRoute = Ember.Route.extend(
model: (params) ->
this.store.find('session', params.id)
)
And the following session.hbs template:
{{#each session_users}}
{{state}}
{{/each}}
I'm connected to a WebSocket stream, when a new SessionUser is created, I get notified.
Here sessions_controller.js.coffee to test pushing some payload:
payload =
id: 20
user: controller.store.getById('user', 2)
session: controller.store.getById('session', 2)
state: 'confirmed'
controller.store.push('sessionUser', payload)
Using Ember Inspector(Chrome Extension) I can see the session user was pushed and is exists in the store with the right relationships, but the template wasn't updated.
When using store.createRecord the template is actually getting updated, but I want to use push/pushPayload so that I can use the existing serializers.