lib/data_table/mongoid.rb in data_table-0.2.3 vs lib/data_table/mongoid.rb in data_table-0.2.4
- old
+ new
@@ -8,10 +8,14 @@
end
def _where_conditions raw_query, search_fields
return if (query = raw_query.gsub(/\//, "")).blank?
- {"$or" => search_fields.map {|field| {field => /#{query}/i} }}
+ if search_fields.size == 1
+ {search_fields.first => /#{query}/i}
+ else
+ {"$or" => search_fields.map {|field| {field => /#{query}/i} }}
+ end
end
def _order_by_fields params, fields
[fields[params[:iSortCol_0].to_i], params[:sSortDir_0]]
end