From 4888a45243ace19b35141741a5625520e9906d14 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 10 Nov 2019 11:48:08 -0500 Subject: [PATCH] Make item titles not required by changesets Fixes a bug where items without titles could not be marked as read --- lib/frenzy/item.ex | 4 ++-- lib/frenzy_web/controllers/item_controller.ex | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/frenzy/item.ex b/lib/frenzy/item.ex index 7e7b28b..5cc236c 100644 --- a/lib/frenzy/item.ex +++ b/lib/frenzy/item.ex @@ -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 diff --git a/lib/frenzy_web/controllers/item_controller.ex b/lib/frenzy_web/controllers/item_controller.ex index 7b95479..2f065c5 100644 --- a/lib/frenzy_web/controllers/item_controller.ex +++ b/lib/frenzy_web/controllers/item_controller.ex @@ -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