Fix: search dossier by id (backoffice)

This commit is contained in:
Julien Portalier 2016-11-17 19:18:24 +01:00
parent 305410f7a3
commit 426fd55f30

View file

@ -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