diff --git a/app/models/mixins/assignment_mixin.rb b/app/models/mixins/assignment_mixin.rb index 9d363184a6a..bf36d6e08ca 100644 --- a/app/models/mixins/assignment_mixin.rb +++ b/app/models/mixins/assignment_mixin.rb @@ -173,6 +173,10 @@ def assignments end end + def tag_class(klass) + klass == "VmOrTemplate" ? "vm" : klass.underscore + end + # @param target # @option options :parents # @option options :tag_list @@ -196,8 +200,7 @@ def get_assigned_for_target(target, options = {}) tlist = Tagging.where("tags.name like '/managed/%'") .where(:taggable => parents) .references(:tag).includes(:tag).map do |t| - klass = t.taggable_type - lower_klass = klass == "VmOrTemplate" ? "vm" : klass.underscore + lower_klass = tag_class(t.taggable_type) "#{lower_klass}/tag#{t.tag.name}" end tagged_resources = tlist.flat_map { |t| assignments_cached[t] }.uniq