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:
parent
ad747a271f
commit
6dbf45775b
2 changed files with 10 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue