demarches-normaliennes/app/controllers/new_gestionnaire/recherche_controller.rb

24 lines
565 B
Ruby
Raw Normal View History

2017-07-31 11:58:52 +02:00
module NewGestionnaire
2017-11-22 09:56:36 +01:00
class RechercheController < GestionnaireController
2017-07-31 11:58:52 +02:00
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