18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/services/forest_liana/search_query_builder.rb', line 18
def search_param
if @params[:search]
conditions = []
@resource.columns.each_with_index do |column, index|
if column.name == 'id'
conditions << "#{@resource.table_name}.id =
#{@params[:search].to_i}"
elsif column.type == :string || column.type == :text
conditions <<
"#{column.name} ILIKE '%#{@params[:search].downcase}%'"
end
end
@records = @resource.where(conditions.join(' OR '))
end
@records
end
|