From dafb04830224131eef63ded8509223374d10157a Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 16 Dec 2019 15:56:13 -0500 Subject: [PATCH] don't error if no tag is given --- lib/philomena_web/templates/profile/user_link/edit.html.slime | 2 +- lib/philomena_web/views/profile/user_link_view.ex | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/templates/profile/user_link/edit.html.slime b/lib/philomena_web/templates/profile/user_link/edit.html.slime index c343de2f..9dcff18a 100644 --- a/lib/philomena_web/templates/profile/user_link/edit.html.slime +++ b/lib/philomena_web/templates/profile/user_link/edit.html.slime @@ -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) \ No newline at end of file += 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) diff --git a/lib/philomena_web/views/profile/user_link_view.ex b/lib/philomena_web/views/profile/user_link_view.ex index d47547a0..b74e006d 100644 --- a/lib/philomena_web/views/profile/user_link_view.ex +++ b/lib/philomena_web/views/profile/user_link_view.ex @@ -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