Update existing model data
See original GitHub issueHi,
Briefly something about our structure. We use Ruby on Rails on the server side with the Trailblazer Framework. On client side Ember and Ember Engines.
Now we have the problem that some models are lying in the father, ie the actual Ember app and some models in the engine. Now the models from the engine still have relations to models which are in the father app. If I now want to update data from this model, the engine model works very well, with the relations (which are in the father) he always makes an INSERT and no UPDATE. There is, of course, an error that the entry already exists.
ActiveRecord::RecordNotUnique - PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "contacts_pkey"
DETAIL: Key (id)=(1) already exists.
Anyone have an idea how to solve the problem and update the engine model and father model? In the Ember Store, everything is correctly linked and the data is also distributed correctly into the relations. On the server comes the following:
Parameters: {"data"=>{"attributes"=>{"patient-number"=>1, "email"=>nil, "employer"=>"", "foreign-doctor"=>"", "family-doctor"=>"", "patient-since"=>"2017-08-02T00:00:00.000Z", "job"=>"", "lab"=>"", "last-therapy"=>"2017-08-02T00:00:00.000Z", "payment-deadline"=>28, "rating"=>1, "recall-type"=>nil, "recommended-by"=>"", "phrophylaxis-user"=>nil, "created-at"=>nil, "updated-at"=>nil, "contact-id"=>nil, "import-id"=>nil}, "relationships"=>{"contact"=>{"data"=>{"type"=>"contacts", "id"=>"1"}}, "customer"=>{"data"=>{"type"=>"customers", "id"=>"1"}}, "patient-insurances"=>{"data"=>[]}, "users"=>{"data"=>[{"type"=>"users", "id"=>"1"}]}, "person"=>{"data"=>{"type"=>"people", "id"=>"1"}}}, "type"=>"patients"}, "id"=>"1", "patient"=>{"data"=>{"attributes"=>{"patient-number"=>1, "email"=>nil, "created-at"=>nil, "updated-at"=>nil}, "relationships"=>{"contact"=>{"data"=>{"type"=>"contacts", "id"=>"1"}}, "person"=>{"data"=>{"type"=>"people", "id"=>"1"}}}, "type"=>"patients"}}}
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
The Solution: https://stackoverflow.com/questions/45487326/update-existing-model-data/45563419#45563419
Ok, thank you for your help 😃