Shopify/batman — Issue #265: isNew is based on presence of id & associations require ids to persist
Author: sandstrom
Created: 2011-12-02 13:34:11+00:00
State: open

`isNew: -> typeof @get('id') is 'undefined'` should depend on something else, since the presence of an id don't necessitate that a model is new:

var m = new App.MyModel;
m.isNew();
=> true
m.set('id', 1);
=> 1
m.isNew()
=> false

This gets confusing since associations require the presence of an id to work, forcing one to add an id before the model is persisted in order to setup associations and save the model. At which stage it looks like the model is already persisted `m.isNew() == false` but really isn't.

* It would be great if `isNew` relied on something other than the presence of an id (there are other situations when one might want to set id's on the client-side).
* Would also be good if associations didn't require an id for inline associations
** or even better for any association until it's persisted (at which point non-inline associations would need an id to persist the association)

https://github.com/Shopify/batman/blob/v0.8.0/src/batman.coffee#L2393