Class: Polysearch::Record

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/polysearch/record.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.arel_search_value(value) ⇒ Object



95
96
97
98
# File 'app/models/polysearch/record.rb', line 95

def arel_search_value(value)
  value = value.to_s.gsub(/\W/, " ").squeeze(" ").downcase.strip
  Arel::Nodes::SqlLiteral.new(sanitize_sql_array(["?", value]))
end

Instance Method Details

#update_value(tsvector_sql) ⇒ Object

public instance methods .….….….….….….….….….….….……



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'app/models/polysearch/record.rb', line 103

def update_value(tsvector_sql)
  sql = "    UPDATE polysearches\n    SET value = (\#{tsvector_sql})\n    WHERE searchable_type = :searchable_type\n    AND searchable_id = :searchable_id;\n  SQL\n  self.class.connection.execute self.class.sanitize_sql_array([\n    sql,\n    searchable_type: searchable_type,\n    searchable_id: searchable_id\n  ])\nend\n"