From beae82aae8f75e9dc43826c06e907522e123f4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 31 Oct 2019 21:45:57 +0100 Subject: [PATCH] Order tags to search by alphabetically We were ordering one group of tags alphabetically and then adding another group of tags which wasn't ordered alphabetically, which didn't make much sense. --- app/helpers/budgets_helper.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 78a3d5a13..943467d86 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -54,9 +54,10 @@ module BudgetsHelper end def investment_tags_select_options(budget, context) - tags = budget.investments.tags_on(context).order(:name).pluck(:name) - tags = tags.concat budget.tag_list_on(context) - tags.uniq + taggables = [budget] + budget.investments + Tag.joins(:taggings) + .merge(Tagging.where(taggable: taggables, context: context)) + .distinct.order(:name).pluck(:name) end def unfeasible_or_unselected_filter