demarches-normaliennes/app/controllers/new_gestionnaire/recherche_controller.rb
2018-01-15 22:14:39 +01:00

23 lines
559 B
Ruby

module NewGestionnaire
class RechercheController < GestionnaireController
def index
@search_terms = params[:q]
# exact id match?
if @search_terms.to_i != 0
@dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i)
end
@dossiers = Dossier.none if @dossiers.nil?
# full text search
if @dossiers.empty?
@dossiers = Search.new(
gestionnaire: current_gestionnaire,
query: @search_terms,
page: params[:page]
).results
end
end
end
end