** (Ecto.ConstraintError) Constraint Error When Attempting To Insert Struct: *

[Solved] ** (Ecto.ConstraintError) Constraint Error When Attempting To Insert Struct: * | Elixir - Code Explorer | yomemimo.com
Question : ** (Ecto.ConstraintError) constraint error when attempting to insert struct: * id_fkey (foreign_key_constraint)

Answered by : tom-zk99pilqv6hu

# This means that the relationship requires a foreign key match in the corresponding table.
# For instance: schema "orders" do belongs_to :client, FulfillmentCart.Clients.Client end schema "client" do has_many :orders, FulfillmentCart.Orders.Order end
### code somewhere else %Order{	client_id: 1 # The value here has to exist in clients table } |> Orders.create_order() # context method to create order
# The client_id needs to have a value that is in the clients table.

Source : | Last Update : Mon, 18 Apr 22

Answers related to ** (Ecto.ConstraintError) constraint error when attempting to insert struct: * id fkey (foreign key constraint)

Code Explorer Popular Question For Elixir