psr7-demo
psr7-demo copied to clipboard
Fork-created model not listening to Firebase
Route:
PortfolioAddAllocationRoute = Ember.Route.extend
beforeModel: ->
@set "fork", @store.fork()
model: (params) ->
@fork.fetch("portfolio", @modelFor("portfolio").get "id").then (portfolioFork) =>
@set "allocation", portfolioFork.get("allocations").pushObject @fork.createRecord "allocation"
@get "allocation"
deactivate: ->
@fork.destroy()
actions:
save: ->
@get("allocation").save().then =>
console.log "Saved"
@transitionTo "portfolio"
cancel: ->
@transitionTo "portfolio"
Later, on the controller for this route:
actions:
addPosition: ->
position = @get("positions").pushObject @get("fork").createRecord "position"
This route is designed to let the user add a new allocation, and when they're done adding positions to it, save it or cancel. However, when I transition after the save, none of the position models (embedded) associated with this new allocation are listening to Firebase (though everything saved just fine). And if I try to view the data for allocation models in Ember Inspector, I get a Uncaught Error: Firebase.child failed: First argument was an invalid path: "undefined". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"
from firebase.js
. If I refresh the page, everything syncs ok. If I don't use a fork, and instead use the regular store, everything works fine (but I lose the auto-self-destruct of the cancel functionality, of course). Is it obvious from this what might be going wrong?