Module: Wildsearcher

Includes:
ActiveRecordHelper
Defined in:
lib/wildsearcher.rb

Instance Method Summary collapse

Instance Method Details

#filter_records(search_fields: [], search_term: "") ⇒ Object



14
15
16
17
18
# File 'lib/wildsearcher.rb', line 14

def filter_records(search_fields: [], search_term: "")
  return version_specific_scoped if search_fields.empty? || search_term.blank?
  check_missing_associations(search_fields)
  where(conditions(filter_fields(search_fields), search_term))
end

#wildsearcher(params = {}) ⇒ Object



8
9
10
11
12
# File 'lib/wildsearcher.rb', line 8

def wildsearcher(params = {})
  field_array = params[:search_fields].to_s.split(",")
  term = params[:search_term].to_s.strip
  filter_records(search_fields: field_array, search_term: term)
end