Cast_assoc invalid

So, when I what to pass the :name option, how do I have to write?
The migration of countries looks as follow:

create table(:countries) do

      add :iso_country, references(:countries_code, column: :iso, type: :string)
      add :iso_language, references(:languages_code, column: :iso, type: :string)
      add :name, :string

      timestamps
    end

Thanks

If you are using the defaults, the Ecto will figure it out for you. If you want to be double sure, you can inspect your foreign key names in the database using any database inspector or you can give a fake name to foreign_key_constraint, something like foreign_key_constraint(..., name: :oops), try to insert data with a foreign key that does not exist, and then follow Ecto error message instructions which will include the proper name,

1 Like

Now I got it.
Thanks so much jose for your help.