diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 5115c5a8c2..2214f4ccff 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -136,19 +136,14 @@ def list @filters, @page, @per_page, @max_results ) - @category = InfoRequest.category_list.find_by(category_tag: @tag) if @tag - if @category - @title = n_('Found {{count}} request in the category ‘{{category}}’', - 'Found {{count}} requests in the category ‘{{category}}’', - @results[:matches_estimated], - count: @results[:matches_estimated], - category: @category.title) - elsif @tag - @title = n_('Found {{count}} request tagged ‘{{tag_name}}’', - 'Found {{count}} requests tagged ‘{{tag_name}}’', - @results[:matches_estimated], - count: @results[:matches_estimated], - tag_name: @tag) + if @tag + @category = InfoRequest.category_list.find_by(category_tag: @tag) + @title = @category&.title + @title ||= n_('Found {{count}} request tagged ‘{{tag_name}}’', + 'Found {{count}} requests tagged ‘{{tag_name}}’', + @results[:matches_estimated], + count: @results[:matches_estimated], + tag_name: @tag) elsif @page > 1 @title = _("Browse and search requests (page {{count}})", count: @page) else