Closed aehrmann closed 8 years ago
I'll have to make the docs better.
You can't assign two associated resources to each other using a =
operator, because of the way we handle associations. For example, you would expect that after assigning the venue to the product, that product would have venueId=...
Not the case, because you did a direct assignment and JavaScript doesn't allow us to override the =
operator, so the method to update that foreign key never gets called.
You have to do the following to assign:
product.assignVenue(venue) # local assignment
product.updateVenue(venue) # sends a request to persist the assignment on the server
So call assignVenue
, then save
product = Product.build()
Venue.first().then (venue) -> product.venue = venue
product.save ->
Expected:
product
saves successfully withproduct.venue
set to loaded venue Actual: Save fails with error:Uncaught TypeError: Converting circular structure to JSON