Class: SearchController

Inherits:
ApplicationController show all
Defined in:
app/controllers/search_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/search_controller.rb', line 2

def index
  @query = params[:q]
  @search = Project.search(params[:q], filters: {
    platform: current_platform,
    normalized_licenses: current_license,
    language: current_language,
    keywords_array: params[:keywords]
  }, sort: format_sort, order: format_order).paginate(page: page_number, per_page: per_page_number)
  @suggestion = @search.response.suggest.did_you_mean.first
  @projects = @search.records.includes(:github_repository)
  @title = page_title
  respond_to do |format|
    format.html
    format.atom
  end
end