lib/data_table/mongoid.rb in data_table-0.3.2 vs lib/data_table/mongoid.rb in data_table-0.3.3
- old
+ new
@@ -17,10 +17,10 @@
if search_fields.size == 1
terms = query.strip.split(/\s+/)
if terms.size == 1
- {search_fields.first => /#{query}/i}
+ {search_fields.first => /#{terms.first}/i}
else
{search_fields.first => {"$all" => terms.map {|term| /#{term}/i }}}
end
else
{"$or" => search_fields.map {|field| {field => /#{query}/i} }}