Module: Care::AutoFinder::Searchable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/care/auto_finder/searchable.rb
Overview
Содержит методы для полнотекстового поиска в коллекции
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #search(items) ⇒ Object
- #search_into_array_field(column) ⇒ Object
- #search_into_joined_field(field_path) ⇒ Object
Instance Method Details
#search(items) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/care/auto_finder/searchable.rb', line 27 def search(items) if params[:search].present? Care::AutoFinder::Searcher.call(items: items, columns: columns, search: params[:search]) else items end end |
#search_into_array_field(column) ⇒ Object
35 36 37 |
# File 'lib/care/auto_finder/searchable.rb', line 35 def search_into_array_field(column) relation.where("array_to_string(#{column}, '||') LIKE ?", "%#{params[:search]}%") end |
#search_into_joined_field(field_path) ⇒ Object
39 40 41 |
# File 'lib/care/auto_finder/searchable.rb', line 39 def search_into_joined_field(field_path) relation.where("#{field_path} LIKE ?", "%#{params[:search]}%") end |