From 426fd55f30857c41e37b993cc3c1fe328a6f90ee Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Thu, 17 Nov 2016 19:18:24 +0100 Subject: [PATCH] Fix: search dossier by id (backoffice) --- .../backoffice/dossiers_controller.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index ce39dbed1..85c5a7b82 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -35,14 +35,19 @@ class Backoffice::DossiersController < Backoffice::DossiersListController def search @search_terms = params[:q] - @dossier = Search.new( - gestionnaire: current_gestionnaire, - query: @search_terms, - page: params[:page] - ).results + # exact id match? + @dossier = Dossier.where(id: @search_terms) + + # full text search + unless @dossier.any? + @dossier ||= Search.new( + gestionnaire: current_gestionnaire, + query: @search_terms, + page: params[:page] + ).results + end smartlisting_dossier @dossier, 'search' - rescue RuntimeError smartlisting_dossier [], 'search' end