don't error if no tag is given

This commit is contained in:
byte[] 2019-12-16 15:56:13 -05:00
parent 03301168c7
commit dafb048302
2 changed files with 4 additions and 1 deletions

View file

@ -1,2 +1,2 @@
h1 Edit Link
= render PhilomenaWeb.Profile.UserLinkView, "_form.html", conn: @conn, changeset: @changeset, tag_name: @user_link.tag.name, action: Routes.profile_user_link_path(@conn, :update, @user_link.user, @user_link)
= render PhilomenaWeb.Profile.UserLinkView, "_form.html", conn: @conn, changeset: @changeset, tag_name: tag_name(@user_link), action: Routes.profile_user_link_path(@conn, :update, @user_link.user, @user_link)

View file

@ -14,4 +14,7 @@ defmodule PhilomenaWeb.Profile.UserLinkView do
def public_as_string(%{public: true}), do: "Yes"
def public_as_string(_user_link), do: "No"
def tag_name(%{tag: nil}), do: nil
def tag_name(%{tag: tag}), do: tag.name
end