Skip to content

Instantly share code, notes, and snippets.

@iHiD
Last active December 15, 2015 20:49
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 iHiD/5321415 to your computer and use it in GitHub Desktop.
Save iHiD/5321415 to your computer and use it in GitHub Desktop.
# Retrieve a belongsTo association
favourite = @get 'user_favourite'
# I'd like to do the following but it makes the
# record dirty, as user_favourite has changed.
# I really don't want user_favourite being tracked,
# But I want to get it with the initial JSON.
favourite.destroyRecord()
Meducation.store.commit()
# Instead - this works but feels v wrong :)
favourite = @get 'user_favourite'
transaction = Meducation.store.transaction()
transaction.add(fav)
favourite.deleteRecord()
favourite.one "didDelete", =>
#...
transaction.commit()
transaction.remove(favourite)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment