defmodule DaProductApp.Chains.Chain do use Ecto.Schema import Ecto.Changeset schema "chains" do field :name, :string belongs_to :brand, DaProductApp.Brands.Brand timestamps() end def changeset(chain, attrs) do chain |> cast(attrs, [:name, :brand_id]) |> validate_required([:name, :brand_id]) end end