Class: Answers::SearchController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Answers::SearchController
- Defined in:
- app/controllers/answers/search_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#after_sign_in_path_for, #redirect_to_back
Instance Method Details
#index ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/answers/search_controller.rb', line 3 def index query = params[:q].strip return redirect_to answers_path if params[:q].blank? results = Question.search(query, index_name: [Question.searchkick_index.name, Answer.searchkick_index.name]) Rails.logger.info "search-request: IP:#{request.env['REMOTE_ADDR']}, params[:query]:#{query}, QUERY:#{query}, FIRST_RESULT:#{results.first.text unless results.empty?}, RESULTS_N:#{results.size}" respond_to do |format| format.json { render json: results } format.html do render locals: { results: results, query: query } end end end |