Skip to content

Commit 17ad5cb

Browse files
committed
use Ecto.Enum for order status
1 parent 9e99095 commit 17ad5cb

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/acme/orders/order.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Acme.Orders.Order do
44

55
schema "orders" do
66
field :account_id, :integer
7-
field :status, :integer
7+
field :status, Ecto.Enum, values: [placed: 1, shipped: 2, delivered: 3]
88

99
timestamps()
1010
end

lib/acme_web/live/order_live/form_component.html.heex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<%= error_tag f, :account_id %>
1515

1616
<%= label f, :status %>
17-
<%= number_input f, :status %>
17+
<%= select f, :status, Ecto.Enum.values(Orders.Order, :status), prompt: "Order status" %>
1818
<%= error_tag f, :status %>
1919

2020
<div>

0 commit comments

Comments
 (0)