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
This commit is contained in:
Jacob Herrington 2020-11-04 11:03:45 -06:00 committed by GitHub
parent ad747a271f
commit 6dbf45775b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -15,7 +15,7 @@
<p>(view full history in notes below)</p>
<ul>
<% @user.roles.each do |role| %>
<li><%= role.name %> <em><%= "- #{Tag.find(role.resource_id).name}" if role.resource_id.present? %></em></li>
<li><%= role.name %> <em><%= role.resource_name.to_s %></em></li>
<% end %>
</ul>
</div>