ruby on rails - How does Ember-Data track associated data? -



ruby on rails - How does Ember-Data track associated data? -

i'm trying come terms ember-data , how associations work.

this application using ember rails.

i've got following:

app.permission = ds.model.extend({ name: ds.attr('string'), description: ds.attr('string'), group: ds.belongsto('group') }); app.group = ds.model.extend({ name: ds.attr('string'), description: ds.attr('string'), permissions: ds.hasmany('permission', {async: true}), user: ds.belongsto('user') }); app.user = ds.model.extend({ username: ds.attr('string'), email: ds.attr('string'), password: ds.attr('string'), groups: ds.hasmany('group', {async: true}) });

for groups, have 2 lists, unselected , selected. html5 drag-and-drop beingness used pull info 1 list other. selected data, in controller, have this:

selectedpermissions: function() { homecoming ember.arrayproxy.createwithmixins(ember.sortablemixin, { sortproperties: ['name'], content: this.get('permissions') }); }.property('model.selectedpermissions')

and works perfectly! permission pulled on selected side automatically saved , associated group.

now, users, again, 2 lists, unselected , selected, , same setup above. selected info in users controller, have this:

selectedgroups: function() { homecoming ember.arrayproxy.createwithmixins(ember.sortablemixin, { sortproperties: ['name'], content: this.get('groups') }); }.property('model.selectedgroups'),

what happens this, reason, when move first grouping or groups over, associated user. however, future alter not. @ info beingness sent rails, , it's sending array of original values, not updated ones.

these 2 closely related code similar. i've verified code right between them.

i know createwithmixins not issue i've tried removing , didn't create difference, else going on.

one of question is: tying "this.get('groups')" selectedgroups, takes ember associate info between them? appears that's happening in group/permission case. don't have other special code doing set things up.

of course, bigger question is, missing here?

any pointers appreciated, i'm lost on one.

i know i've posted few pieces of code, it's plenty work with.

ruby-on-rails ember.js ember-data

Comments