Skip to content

Instantly share code, notes, and snippets.

@arjan
Created April 11, 2017 20:23
Show Gist options
  • Save arjan/fee1d758eef3aaca2456be7de439cc43 to your computer and use it in GitHub Desktop.
Save arjan/fee1d758eef3aaca2456be7de439cc43 to your computer and use it in GitHub Desktop.
defmodule Property do
use Ecto.Schema
@primary_key false
schema "property" do
field :id, :integer, primary_key: true
belongs_to :model, Model, foreign_key: :model_id
end
end
defmodule Model do
use Ecto.Schema
@primary_key false
schema "model" do
field :id, :integer, primary_key: true
has_many :properties, Property, foreign_key: :model_id
end
end
# == Compilation error on file lib/tst.ex ==
# ** (ArgumentError) argument error
# lib/ecto/association.ex:474: Ecto.Association.Has.get_ref/3
# lib/ecto/association.ex:424: Ecto.Association.Has.struct/3
# lib/ecto/schema.ex:1679: Ecto.Schema.association/5
# lib/ecto/schema.ex:1474: Ecto.Schema.__has_many__/4
# lib/tst.ex:17: (module)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment