diff options
Diffstat (limited to 'app/helpers/public_body_helper.rb')
-rw-r--r-- | app/helpers/public_body_helper.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb index 57c90a9ba..b8e59a341 100644 --- a/app/helpers/public_body_helper.rb +++ b/app/helpers/public_body_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding : utf-8 -*- module PublicBodyHelper # Public: The reasons a request can't be made to a PublicBody @@ -36,22 +37,19 @@ module PublicBodyHelper # # public_body - Instance of a PublicBody # - # Returns a string + # Returns a String def type_of_authority(public_body) - first = true - types = public_body.tags.each.map do |tag| - if PublicBodyCategory.get().by_tag().include?(tag.name) - desc = PublicBodyCategory.get().singular_by_tag()[tag.name] - if first - desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } - first = false - end - link_to(desc, list_public_bodies_path(tag.name)) + categories = PublicBodyCategory. + where(:category_tag => public_body.tag_string.split) + + types = categories.each_with_index.map do |category, index| + desc = category.description + if index.zero? + desc = desc.sub(/\S/) { |m| Unicode.upcase(m) } end + link_to(desc, list_public_bodies_path(category.category_tag)) end - types.compact! - if types.any? types.to_sentence(:last_word_connector => ' and ').html_safe else |