ebryn / ember-model

A lightweight model library for Ember.js
MIT License
524 stars 159 forks source link

Embedded belongsTo dirty tracking #355

Closed ahacking closed 10 years ago

ahacking commented 10 years ago

I am finding that changes to properties within embedded belongsTo relationships don't record the dirty change in the outer model as is done for hasMany. I can understand this would be unexpected in the non embedded case given the ownership connotations of belongsTo but certainly not for the embedded case.

A typical/example use case is a Person model with an embedded Address is never marked dirty when the address fields are modified in a web form. A Save button with its enabled state based on the isDirty property of controller.content (ie the Contact model) is therefore never enabled.

As an aside I'm not a fan of the ownership based naming (especially in the embedded belongsTo case) and much prefer pure cardinality based naming like hasOne and hasMany. Has consideration been given to changing the name so it doesn't convey ownership semantics? I added an alias method hasOne to my use of Ember.Model so the model definitions make sense reading them.

ebryn commented 10 years ago

Hmm... can you verify you are using the latest build of Ember Model? http://builds.erikbryn.com/ember-model/ember-model-latest.js

ahacking commented 10 years ago

OK.

I was using master in my bower.json (I use brunch and bower for my client development workflow):

"ember-model": "ebryn/ember-model"

But I have now switched back to latest as per your url:

"ember-model": "http://builds.erikbryn.com/ember-model/ember-model-latest.js",

Brunch kicked off bower, rebuilt my vendor js, the page auto-refreshed and it is now working correctly.

So it looks like there is a regression in master then.

Thanks for your help!

ebryn commented 10 years ago

@ahacking If you use bower, you're not on master. ember-model-latest.js is master.