mobilizon/lib/eventos/events/tag.ex
Thomas Citharel 90ceb4f6fe initial commit
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2017-12-08 09:58:14 +01:00

22 lines
379 B
Elixir

defmodule Eventos.Events.Tag do
use Ecto.Schema
import Ecto.Changeset
alias Eventos.Events.Tag
schema "tags" do
field :slug, :string
field :title, :string
timestamps()
end
@doc false
def changeset(%Tag{} = tag, attrs) do
tag
|> cast(attrs, [:title, :slug])
|> validate_required([:title, :slug])
|> unique_constraint(:slug)
end
end