Method: Spree::Product.like_any
- Defined in:
- app/models/spree/product.rb
.like_any(fields, values) ⇒ ActiveRecord::Relation
Poor man’s full text search.
Filters products to those which have any of the strings in values
in any of the fields in fields
.
199 200 201 202 203 204 |
# File 'app/models/spree/product.rb', line 199 def self.like_any(fields, values) conditions = fields.product(values).map do |(field, value)| arel_table[field].matches("%#{value}%") end where conditions.inject(:or) end |