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:
parent
a5fb5216ce
commit
4888a45243
|
@ -59,7 +59,7 @@ defmodule Frenzy.Item do
|
||||||
url: String.t(),
|
url: String.t(),
|
||||||
read: boolean(),
|
read: boolean(),
|
||||||
read_date: DateTime.t(),
|
read_date: DateTime.t(),
|
||||||
title: String.t(),
|
title: String.t() | nil,
|
||||||
tombstone: boolean(),
|
tombstone: boolean(),
|
||||||
feed: Frenzy.Feed.t() | Ecto.Association.NotLoaded.t(),
|
feed: Frenzy.Feed.t() | Ecto.Association.NotLoaded.t(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: NaiveDateTime.t(),
|
||||||
|
@ -70,6 +70,6 @@ defmodule Frenzy.Item do
|
||||||
def changeset(item, attrs) do
|
def changeset(item, attrs) do
|
||||||
item
|
item
|
||||||
|> cast(attrs, [:guid, :title, :url, :creator, :date, :content, :read, :read_date, :tombstone])
|
|> 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
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,7 +44,7 @@ defmodule FrenzyWeb.ItemController do
|
||||||
read_date: Timex.now()
|
read_date: Timex.now()
|
||||||
})
|
})
|
||||||
|
|
||||||
Repo.update(changeset)
|
{:ok, item} = Repo.update(changeset)
|
||||||
redirect(conn, to: Routes.item_path(Endpoint, :show, item.id))
|
redirect(conn, to: Routes.item_path(Endpoint, :show, item.id))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue