Module: Plotline::Concerns::Searchable::ClassMethods

Defined in:
app/models/plotline/concerns/searchable.rb

Instance Method Summary collapse

Instance Method Details

#search(query) ⇒ Object



18
19
20
21
22
23
# File 'app/models/plotline/concerns/searchable.rb', line 18

def search(query)
  select('DISTINCT ON (entry_id) entry_id, plotline_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



13
14
15
16
# File 'app/models/plotline/concerns/searchable.rb', line 13

def searchable_attributes(*args)
  @searchable_attributes = args if args.any?
  @searchable_attributes ||= []
end