Class: AdvancedSearchController

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

Overview

Controller for the Advanced Search page. This was initially made to handle searches for Custom Metadata, but the ambition is to consolidate some other search functionality (Lab View, Lab Search) into this page.

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#indexObject



8
9
10
11
# File 'app/controllers/advanced_search_controller.rb', line 8

def index
  @searched = false
  parse_params
end

#parse_paramsObject



24
25
26
27
# File 'app/controllers/advanced_search_controller.rb', line 24

def parse_params
  @key_search_term = params['metadata_key']
  @value_search_term = params['metadata_value']
end

#searchObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/advanced_search_controller.rb', line 13

def search
  @searched = true
  parse_params

  if @key_search_term.present? && @value_search_term.present?
    @results = CustomMetadatum.where(key: @key_search_term, value: @value_search_term)
  end

  render :index
end