Skip to content

Instantly share code, notes, and snippets.

@jacobk
Created March 8, 2013 08:53
Show Gist options
  • Save jacobk/5115100 to your computer and use it in GitHub Desktop.
Save jacobk/5115100 to your computer and use it in GitHub Desktop.
App.ComposeRoute = Ember.Route.extend({
model: function() {
return this.ensureMessage();
},
createMessage: function() {
var transaction = this.get('store').transaction(),
message = transaction.createRecord(App.Message, {});
return message;
},
ensureMessage: function() {
var app = this.controllerFor('application'),
modelProp = 'composingMessage',
model = app.get(modelProp);
if (model === undefined) {
model = this.createMessage();
app.set(modelProp, model);
}
return model;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment