diff --git a/lib/philomena/channels/channel.ex b/lib/philomena/channels/channel.ex index f3585cb9..a7136257 100644 --- a/lib/philomena/channels/channel.ex +++ b/lib/philomena/channels/channel.ex @@ -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 diff --git a/lib/philomena_web/templates/channel/new.html.slime b/lib/philomena_web/templates/channel/new.html.slime index f3293068..8a3551e9 100644 --- a/lib/philomena_web/templates/channel/new.html.slime +++ b/lib/philomena_web/templates/channel/new.html.slime @@ -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