Add Articles
mix phx.gen.live Articles Article articles title:string\ /Crucial/git/phoenix-liveview-book content:text url:string language:string\ date:utc_datetime author_id:references:authors
This commit is contained in:
24
lib/outlook/articles/article.ex
Normal file
24
lib/outlook/articles/article.ex
Normal file
@ -0,0 +1,24 @@
|
||||
defmodule Outlook.Articles.Article do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Outlook.Authors.Author
|
||||
|
||||
schema "articles" do
|
||||
field :content, :string
|
||||
field :date, :utc_datetime
|
||||
field :language, :string
|
||||
field :title, :string
|
||||
field :url, :string
|
||||
belongs_to :author, Author
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(article, attrs) do
|
||||
article
|
||||
|> cast(attrs, [:title, :content, :url, :language, :date])
|
||||
|> validate_required([:title, :content, :url, :language, :date])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user