Commit 73479a2c7c52e323c027dc83ad06f157d221ca17
1 parent
cd32f252
Exists in
master
and in
29 other branches
application_helper/rolename: improve performance retrieval and readability
Showing
1 changed file
with
4 additions
and
1 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -727,7 +727,10 @@ module ApplicationHelper |
727 | 727 | end |
728 | 728 | |
729 | 729 | def rolename_for(profile, resource) |
730 | - roles = profile.role_assignments.select{ |a| a.resource_id == resource.id }.sort_by{ |s| s.role_id }.map(&:role) | |
730 | + roles = profile.role_assignments. | |
731 | + where(:resource_id => resource.id). | |
732 | + sort_by{ |role_assignment| role_assignment.role_id }. | |
733 | + map(&:role) | |
731 | 734 | names = [] |
732 | 735 | roles.each do |role| |
733 | 736 | names << content_tag('span', role.name, :style => "color: #{role_color(role, resource.environment.id)}") | ... | ... |