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
descriptors update (ActiveRecord::RecordNotDestroyed) "Failed to destroy the record" #2713
Comments
Not sure either, it looks like somebody tried to delete a descriptor on a sandbox. But that descriptor has several char_states and numerous obseravtion. It should not be deletable. May be just the error have to be handled more nicely? |
This was an Since this is a sandbox I'll assume it is safe to publish the params: {
"descriptor" => {
"name" => "Body form",
"short_name" => "Body form",
"description" => "{proportion between length and width}",
"default_unit" => nil,
"type" => "Descriptor::Qualitative",
"position" => 9874,
"description_name" => "Body form",
"key_name" => "Body form",
"weight" => nil,
"gene_attribute_logic" => nil,
"character_states_attributes" => [
[0] {
"id" => 878,
"name" => "slender, length more than 5 times maximum width",
"description_name" => "slender",
"key_name" => "slender",
"label" => "0",
"descriptor_id" => 923,
"position" => 1
},
[1] {
"id" => 1979,
"name" => "moderate, length between 2 to 4 times maximum width",
"description_name" => "moderate or robust",
"key_name" => "moderate or robust",
"label" => "1",
"descriptor_id" => 923,
"position" => 2
},
[2] {
"id" => 3253,
"name" => "robust, lenght less than or equal to two times maximum width",
"description_name" => nil,
"key_name" => nil,
"label" => "2",
"descriptor_id" => 923,
"position" => 3,
"_destroy" => true
}
]
},
"controller" => "descriptors",
"action" => "update",
"id" => "923",
"format" => "json"
} Looking at this prettier representation of the params I see last one is marked to be destroyed (while at the same time all the fields values are also provided). |
Fix was for something else. Reopening. |
Solved by catching raise, might be missing something in related models, particularly before/after, but nothing obvious hit. Apparently this is expected behaviour if you have dependent => destroy => despendent => destroy (restrict with error) chains. |
An ActiveRecord::RecordNotDestroyed occurred in descriptors#update:
Failed to destroy the record
app/controllers/descriptors_controller.rb:62:in `block in update'
Github link:
https://github.com/SpeciesFileGroup/taxonworks/blob/6da13f6e5/app/controllers/descriptors_controller.rb#L62
I'm unsure what happens here. Does the frontend supply the complete desired database state (scoped to one descriptor) and not just what needs to be updated, created or deleted?
The text was updated successfully, but these errors were encountered: