Module: Recourse::Searchable

Defined in:
lib/recourse/searchable.rb

Overview

Extends any model to be searchable with Ransack.

Instance Method Summary collapse

Instance Method Details

#filter_fieldsObject

Note:

to be overriden by subclasses -- the name of the field to filter by.



29
# File 'lib/recourse/searchable.rb', line 29

def filter_fields = {}

#ransackable_associations(auth_object = nil) ⇒ Object

Returns the associations that can be searched (by default: none).



11
12
13
# File 'lib/recourse/searchable.rb', line 11

def ransackable_associations(auth_object = nil)
  %w[ ]
end

#ransackable_attributes(auth_object = nil) ⇒ Object

Returns the attributes that can be searched.



6
7
8
# File 'lib/recourse/searchable.rb', line 6

def ransackable_attributes(auth_object = nil)
  %w[ ]
end

#ransortable_attributes(auth_object = nil) ⇒ Object

Returns the associations that can be sorted by (by default: none).



16
17
18
# File 'lib/recourse/searchable.rb', line 16

def ransortable_attributes(auth_object = nil)
  %w[ ]
end

#search_fieldObject

Note:

to be overriden by subclasses -- the name of the field to search with.



21
22
# File 'lib/recourse/searchable.rb', line 21

def search_field
end

#search_promptObject

Note:

to be overriden by subclasses -- the placeholder for the field to search with.



25
26
# File 'lib/recourse/searchable.rb', line 25

def search_prompt
end

#searchable_fieldsObject

Returns the names of all the search and filter fields.



32
# File 'lib/recourse/searchable.rb', line 32

def searchable_fields = [search_field, filter_fields.keys]