Class: SearchrRails::SearchController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SearchrRails::SearchController
- Defined in:
- app/controllers/searchr_rails/search_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.search_query_class ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/searchr_rails/search_controller.rb', line 5 def self.search_query_class unless @search_klass raise 'You must call SearchrRails::SearchController.search_query_class = AQueryClass (should be a subclass of Searchr::SolrQuery' end @search_klass end |
.search_query_class=(klass) ⇒ Object
12 13 14 |
# File 'app/controllers/searchr_rails/search_controller.rb', line 12 def self.search_query_class=(klass) @search_klass = klass end |
Instance Method Details
#ignore_errors ⇒ Object
34 35 36 37 |
# File 'app/controllers/searchr_rails/search_controller.rb', line 34 def ignore_errors yield rescue end |
#index ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/searchr_rails/search_controller.rb', line 16 def index query = self.class.search_query_class.new query.query = params[:query] if params[:query] ignore_errors{ query.start_row = Integer(params[:start_row]) if params[:start_row] } ignore_errors{ query.num_rows = Integer(params[:num_rows]) if params[:num_rows] } query.fields_to_query = params[:query_fields] if params[:query_fields] query.fields_to_return = params[:fields_to_return] if params[:fields_to_return] result = query.search data = { result: result, show_fields: query.fields_to_return, params: params } respond_to do |format| format.html { render locals: data } format.json { render json: data, status: solr.status } end end |