diff options
-rw-r--r-- | app/finders/base_finder.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/finders/base_finder.rb b/app/finders/base_finder.rb index ad63135e7e6..ec5f5919d7e 100644 --- a/app/finders/base_finder.rb +++ b/app/finders/base_finder.rb @@ -125,7 +125,13 @@ class BaseFinder def by_label(items) if params[:label_name].present? - items = items.joins(:labels).where("labels.title in (?)", params[:label_name].split(",")) + label_names = params[:label_name].split(",") + + item_ids = LabelLink.joins(:label). + where('labels.title in (?)', label_names). + where(target_type: klass.name).pluck(:target_id) + + items = items.where(id: item_ids) end items |