Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating the status of a hasMany relationship blows up #442

Closed
mehulkar opened this issue Oct 29, 2012 · 3 comments
Closed

updating the status of a hasMany relationship blows up #442

mehulkar opened this issue Oct 29, 2012 · 3 comments
Labels
🏷️ bug This PR primarily fixes a reported issue

Comments

@mehulkar
Copy link

Talked with @wycats about this. I was trying to embed a hasMany relationship on store commit and it wouldn't allow me to update the relationship on success. The difference between the two is the order. Currently you have to update the relationship before you update the record.

This fails:

createRecord: (store,type,record) ->
  root = @rootForType(type)
  data = {}
  data[root] = @toJSON(record, { includeId: true })
  posts = []

  record.get("posts").forEach (p) ->
    posts.pushObject p.toJSON()

  data[root]["posts"] = posts

  store = App.router.get('store')
  @ajax @buildURL(root), "POST", {
  data: data
  context: this
  success: (json) ->
    # this order is important
    @didCreateRecord(store,type,record,json)
    record.get('posts').forEach (p) ->
      store.didUpdateRelationship(p, 'author')
  }

## updating the relationship before calling `didCreateRecord` works
  success: (json) ->
    record.get('posts').forEach (p) ->
    store.didUpdateRelationship(p, 'author')
    @didCreateRecord(store,type,record,json)
@elliterate
Copy link
Contributor

What error did you get?

@mehulkar
Copy link
Author

I don't remember what the exact error was, but I think the either post or author didn't change it's inFlight state.

@igorT
Copy link
Member

igorT commented Apr 15, 2013

A lot of this code has changed so closing due to inactivity. Happy to reopen if its still an issue.

@igorT igorT closed this as completed Apr 15, 2013
@runspired runspired added 🏷️ bug This PR primarily fixes a reported issue and removed Bug labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bug This PR primarily fixes a reported issue
Projects
None yet
Development

No branches or pull requests

4 participants