Created
March 8, 2013 08:53
-
-
Save jacobk/5115100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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