fix channel creation errors

This commit is contained in:
byte[] 2019-12-31 19:54:19 -05:00
parent 9b22d2719a
commit 7473b92309
2 changed files with 4 additions and 5 deletions

View file

@ -38,10 +38,9 @@ defmodule Philomena.Channels.Channel do
@doc false
def changeset(channel, attrs) do
tag_id =
if attrs["artist_tag"] do
Repo.get_by(Tag, name: attrs["artist_tag"]).id
else
nil
case Repo.get_by(Tag, name: attrs["artist_tag"] || "") do
%{id: id} -> id
_ -> nil
end
channel

View file

@ -1,3 +1,3 @@
h1 Adding Channel
= render PhilomenaWeb.ChannelView, "_form.html", changeset: @changeset, action: Routes.channel_path(@conn, :new), conn: @conn
= render PhilomenaWeb.ChannelView, "_form.html", changeset: @changeset, action: Routes.channel_path(@conn, :create), conn: @conn