question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update existing model data

See original GitHub issue

Hi,

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:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

0reactions
dmtaskcommented, Aug 3, 2017

Ok, thank you for your help 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to: Update a Model from an Existing Database
How to Update a Domain Model when the Database Changes · Open the Visual Designer, right-click on an empty area and select Update...
Read more >
python - How do I update an already existing row when using ...
To update an existing row (or object in ORM-speak), you have to tell the ModelForm what instance to use when instantiating it:
Read more >
Updating an existing model
Select Tools→Generate Model type to display the generation dialog box. Select the Update Existing Model type radio button. Select a model from the...
Read more >
How to Update Neural Network Models With More Data
We can update the model on a combination of both old and new data. An extreme version of this approach is to discard...
Read more >
Update a Model Object With a ModelForm - OpenClassrooms
Now that we've created model objects, we need to be able to update them. Time to choose a URL pattern for our next...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found