RoR OCIError: ORA-02291: integrity constraint violated - parent key not found

119 views Asked by At

I was dev a RoR application and before I drop accidentaly 4 of my tables wich 2 has FKs to the anothers 2 so when I restore it and make the tables "stable" I try to insert a record that contain fk from pacientes,hclinicos and dientes

OCIError: ORA-02291: integrity constraint (FELIPE.ODONTODIAGRAMAS_DIENTE_ID_FK) violated -
          parent key not found:
            INSERT INTO "ODONTODIAGRAMAS" ("DIENTE_ID", "SIMBOLOGIA_ID", "HCLINICO_ID", "CREATED_AT", "UPDATED_AT", "ID")
            VALUES (:a1, :a2, :a3, :a4, :a5, :a6)

FELIPE is the database, ODONTODIAGRAMAS is the table, which I am inserting and DIENTE is another table that contains multiple records and I render them in hclinico_new view to save them in another table

This is how I render the DIENTES to save them

<%= f.fields_for :odontodiagramas do |odontodiagramas_for_form| %>
  <div class="form-group">
    <label for="textArea" class="col-md-2 control-label"><%= Diente.find(1).referencia %></label>
    <div class="col-md-10">
      <%= odontodiagramas_for_form.collection_select :simbologia_id, Simbologia.all, :id, :simbolo, { prompt: "Estado" }, { class: "form-control" } %>
      <%= odontodiagramas_for_form.hidden_field :diente_id, :value => Diente.find(1) %>
      <%= odontodiagramas_for_form.hidden_field :_destroy %>
 <!-- <span class="help-block"></span> -->
    </div>
  </div>

of course they are more than 1.maybe its an error in the db composition?.the weird is that this is not the only table that insert a constraint in another table so I dont understand why Im getting this error

0

There are 0 answers