shift73k/lib/bones73k/properties/property.ex

27 lines
610 B
Elixir
Raw Normal View History

2021-02-24 07:49:39 -05:00
defmodule Bones73k.Properties.Property do
2020-09-14 12:22:25 -04:00
use Ecto.Schema
import Ecto.Changeset
schema "properties" do
field :description, :string
field :name, :string
field :price, :decimal
field :user_id, :id
timestamps()
end
2020-09-14 19:45:56 -04:00
def create_changeset(property, attrs) do
property
|> cast(attrs, [:name, :price, :description, :user_id])
|> validate_required([:name, :price, :description, :user_id])
end
2020-09-14 12:22:25 -04:00
@doc false
def changeset(property, attrs) do
property
|> cast(attrs, [:name, :price, :description])
|> validate_required([:name, :price, :description])
end
end