From 32fbc4e65fa88b2e17cecb6356b9193f334d7035 Mon Sep 17 00:00:00 2001 From: Lily Date: Sat, 12 Nov 2022 09:21:20 -0400 Subject: [PATCH] wiki pages: don't show create links to anonymous users on non-existent pages --- app/views/wiki_pages/show.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb index d3d01eaa2..ebde6adb2 100644 --- a/app/views/wiki_pages/show.html.erb +++ b/app/views/wiki_pages/show.html.erb @@ -27,7 +27,11 @@ <% end %> <% if @wiki_page.new_record? %> -

This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(wiki_page: { title: @wiki_page.title }), rel: "nofollow" %>.

+

This wiki page does not exist. + <% if policy(@wiki_page).create? %> + <%= link_to "Create new wiki page", new_wiki_page_path(wiki_page: { title: @wiki_page.title }), rel: "nofollow" %>.

+ <% end %> +

<% else %> <%= format_text(@wiki_page.body) %> <% end %>