From cdc142592a306c282548a6d775b3a0145beeca47 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 6 Sep 2020 16:23:24 -0400 Subject: [PATCH] require tag to exist on user link creation --- lib/philomena/user_links/user_link.ex | 1 + lib/philomena_web/templates/profile/user_link/_form.html.slime | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/philomena/user_links/user_link.ex b/lib/philomena/user_links/user_link.ex index b79ffbf4..48e3ba79 100644 --- a/lib/philomena/user_links/user_link.ex +++ b/lib/philomena/user_links/user_link.ex @@ -52,6 +52,7 @@ defmodule Philomena.UserLinks.UserLink do |> put_assoc(:tag, tag) |> put_assoc(:user, user) |> validate_required([:user, :uri, :public]) + |> validate_required([:tag], message: "must exist") |> validate_format(:uri, ~r|\Ahttps?://|) |> parse_uri() |> put_verification_code() diff --git a/lib/philomena_web/templates/profile/user_link/_form.html.slime b/lib/philomena_web/templates/profile/user_link/_form.html.slime index 0fa3d608..a3dac77a 100644 --- a/lib/philomena_web/templates/profile/user_link/_form.html.slime +++ b/lib/philomena_web/templates/profile/user_link/_form.html.slime @@ -14,8 +14,8 @@ | artist: em artist name here ' or a series name - p Should be blank only if your content isn't on the site, generally = text_input f, :tag_name, value: assigns[:tag_name], class: "input", autocomplete: "off", placeholder: "artist:name", data: [ac: "true", ac_min_length: "3", ac_source: "/tags/autocomplete?term="] + = error_tag f, :tag .field label for="uri"