Class: Polysearch::Record
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Polysearch::Record
- Defined in:
- app/models/polysearch/record.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#update_value(tsvector_sql) ⇒ Object
public instance methods .….….….….….….….….….….….……
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 = <<~SQL UPDATE polysearches SET value = (#{tsvector_sql}) WHERE searchable_type = :searchable_type AND searchable_id = :searchable_id; SQL self.class.connection.execute self.class.sanitize_sql_array([ sql, searchable_type: searchable_type, searchable_id: searchable_id ]) end |