Skip to content

Instantly share code, notes, and snippets.

@shankardevy

shankardevy/order.ex Secret

Created Jul 8, 2017
Embed
What would you like to do?
defmodule Mango.Sales.Order do
use Ecto.Schema
import Ecto.Changeset
alias Mango.Sales.Order
schema "orders" do
field :line_items, {:array, :map}
field :status, :string
field :total, :decimal
timestamps()
end
@doc false
def changeset(%Order{} = order, attrs) do
order
|> cast(attrs, [:status, :total, :line_items])
|> validate_required([:status, :total, :line_items])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment