You might show the appointment migration file.
defmodule Medica.Repo.Migrations.CreateAppointments do
use Ecto.Migration
def change do
create table(:appointments) do
add :rut_paciente, :string
add :fecha, :date
add :id_medico, references(:medics)
add :bloque, :integer
add :descripcion, :text
timestamps()
end
create unique_index(:appointments, [:fecha, :bloque, :id_medico])
end
end
Well itâs clearer now, You donât have this key.
Replace
add :id_medico, references(:medics)
# with
add :medic_id, references(:medics)
Or use foreign_key options to specify a custom key.
That may be it, it was wrong to mix some spanish in between haha, thanks, Iâll do that and check again the multiple_select.
Ok, I did everything and now it doesânt give phoenix errors, but It keeps giving is_invalid
error under the medics field.
%{
"bloque" => "25",
"descripcion" => "Example",
"fecha" => %{"day" => "1", "month" => "9", "year" => "2013"},
"medic_id" => ["2"],
"rut_paciente" => "19.386.399-K"
}
It does send the correct data though.
It does not because You use multiselectâŠ
"medic_id" => ["2"],
# but You are expecting an id, like this
"medic_id" => "2",
It returns a list of id, so You need to unwrap and take first
1 Like
That did the trick, thanks.