lib/snaptable/constructor/collection.rb in snaptable-2.1.0 vs lib/snaptable/constructor/collection.rb in snaptable-2.2.0
- old
+ new
@@ -10,21 +10,21 @@
@records ||= filter(collection).paginate(page: params[paginate_key], per_page: 30).order(sort_column + " " + sort_direction)
end
def filter(collection)
if options[:search] == true && !params[:query].blank?
- collection.joins(search_associations).where(query, query: "%#{params[:query]}%", id: params[:query].to_i)
+ collection.joins(search_associations).where(query, query: "%#{params[:query].downcase}%", id: params[:query].to_i)
else
collection
end
end
private
def query
query_fields.map do |key, values|
values.map do |value|
- "#{key}.#{value} LIKE :query OR"
+ "LOWER(#{key}.#{value}) LIKE :query OR"
end.join(" ")
end.join(" ") + " #{column_name('id')} = :id"
end
def query_fields