JOL/lib/jol/blog/post.ex

21 lines
437 B
Elixir

defmodule JOL.Blog.Post do
use Ecto.Schema
import Ecto.Changeset
schema "posts" do
field :title, :string
field :body, :string
field :published_at, :naive_datetime
field :slug, :string
timestamps(type: :utc_datetime)
end
@doc false
def changeset(post, attrs) do
post
|> cast(attrs, [:title, :body, :published_at, :slug])
|> validate_required([:title, :body, :published_at, :slug])
end
end