From 6dbf45775bd429a87e40a596eb6a35b7c8bcb032 Mon Sep 17 00:00:00 2001 From: Jacob Herrington Date: Wed, 4 Nov 2020 11:03:45 -0600 Subject: [PATCH] List single_resource_admin resources in the UI (#11049) * List single_resource_admin resources in the UI * Add a comment to explain Role#resource_name --- app/models/role.rb | 9 +++++++++ app/views/admin/users/_activity.html.erb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/role.rb b/app/models/role.rb index c86a0c5bd..d77fcf542 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -32,4 +32,13 @@ class Role < ApplicationRecord inclusion: { in: ROLES } scopify + + # Returns a somewhat friendly name for the resource related to a given role. + # In the case of Tag Moderators, a resource_type is not present, so we use the + # resource_id to grab the specific Tag related to that moderator's role. + def resource_name + return resource_type unless resource_id + + Tag.find(resource_id).name + end end diff --git a/app/views/admin/users/_activity.html.erb b/app/views/admin/users/_activity.html.erb index a3ce5b75f..92f44cfff 100644 --- a/app/views/admin/users/_activity.html.erb +++ b/app/views/admin/users/_activity.html.erb @@ -15,7 +15,7 @@

(view full history in notes below)