From c53370e14c19f8b611a510e90c35b4923f9c2236 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Tue, 19 Feb 2019 17:03:29 +0100 Subject: [PATCH] [#3477] Reuse existing filtering facility --- app/models/procedure_presentation.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index e413513a6..8b86e6f2d 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -168,11 +168,8 @@ class ProcedurePresentation < ApplicationRecord dossiers = dossiers.includes(:champs_private).references(:champs_private) end - where_conditions = fields.map do |field| - "champs.type_de_champ_id = #{field['column']}" - end.join(" OR ") - - dossiers.where(where_conditions) + Filter.new(dossiers) + .where_equals('champs.type_de_champ_id', fields.pluck('column')) end end end