Make item titles not required by changesets

Fixes a bug where items without titles could not be marked as read
This commit is contained in:
Shadowfacts 2019-11-10 11:48:08 -05:00
parent a5fb5216ce
commit 4888a45243
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 3 additions and 3 deletions

View File

@ -59,7 +59,7 @@ defmodule Frenzy.Item do
url: String.t(),
read: boolean(),
read_date: DateTime.t(),
title: String.t(),
title: String.t() | nil,
tombstone: boolean(),
feed: Frenzy.Feed.t() | Ecto.Association.NotLoaded.t(),
inserted_at: NaiveDateTime.t(),
@ -70,6 +70,6 @@ defmodule Frenzy.Item do
def changeset(item, attrs) do
item
|> cast(attrs, [:guid, :title, :url, :creator, :date, :content, :read, :read_date, :tombstone])
|> validate_required([:guid, :title, :url, :date, :content, :feed])
|> validate_required([:guid, :url, :date, :content, :feed])
end
end

View File

@ -44,7 +44,7 @@ defmodule FrenzyWeb.ItemController do
read_date: Timex.now()
})
Repo.update(changeset)
{:ok, item} = Repo.update(changeset)
redirect(conn, to: Routes.item_path(Endpoint, :show, item.id))
end