Module: Ucpengine::Concerns::Searchable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Entry
- Defined in:
- app/models/ucpengine/concerns/searchable.rb
Instance Method Summary collapse
Instance Method Details
#search(query) ⇒ Object
16 17 18 19 20 21 |
# File 'app/models/ucpengine/concerns/searchable.rb', line 16 def search(query) select('DISTINCT ON (entry_id) entry_id, wellspring_entries.*'). joins(:search_data). where("search_data @@ plainto_tsquery('english', :q)", q: query). order("entry_id, ts_rank(search_data, plainto_tsquery('%s')) desc" % send(:sanitize_sql, query)) end |
#searchable_attributes(*args) ⇒ Object
11 12 13 14 |
# File 'app/models/ucpengine/concerns/searchable.rb', line 11 def searchable_attributes(*args) @searchable_attributes = args if args.any? @searchable_attributes ||= [] end |