Class: SmartSearchTag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SmartSearchTag
- Defined in:
- lib/smart_search_tag.rb
Overview
Represents the search index
Class Method Summary collapse
-
.tags_list(query, table = nil) ⇒ Object
Get a list of available search tags.
Class Method Details
.tags_list(query, table = nil) ⇒ Object
Get a list of available search tags
6 7 8 9 10 11 12 13 14 |
# File 'lib/smart_search_tag.rb', line 6 def self.(query, table= nil) if query.size < 3 return [] else list = sql_query!("select search_tags from #{self.table_name} where search_tags like '%#{query}%' #{"and table_name = '#{table}'" if table} ").map {|r| r['search_tags']} list = list.join(" ").clear_html.split(" ").uniq return list.sort.grep(Regexp.new(query)) end end |