Skip to content

Instantly share code, notes, and snippets.

@arekt
Created February 7, 2014 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arekt/8855962 to your computer and use it in GitHub Desktop.
Save arekt/8855962 to your computer and use it in GitHub Desktop.
Chaining ember promises in coffeescript
addProblem: (disease) ->
Ordering.MedicalRecord.store.find("medicalRecord",2)
.then (mr) =>
mr.get("problems")
.then (problems) =>
o = @store.createRecord("problem", {disease: disease, medicalRecord: mr})
.then (p) ->
p.save().then ->
console.log "Problem was saved correctly!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment