lib/generators/dry_crud/templates/app/controllers/list_controller.rb
# Compose the search condition with a basic SQL OR query.
Compose the search condition with a basic SQL OR query.
Compose the search condition with a basic SQL OR query .
def search_condition
      if search_support? && params[:q].present?
        terms = params[:q].split(/\s+/).collect { |t| "%#{t}%" }
        clause = search_columns.collect do |f|
          col = f.to_s.include?('.') ? f : "#{model_class.table_name}.#{f}"
          "#{col} LIKE ?"
        end.join(" OR ")
        clause = terms.collect {|t| "(#{clause})" }.join(" AND ")
         ["(#{clause})"] + terms.collect {|t| [t] * search_columns.size }.flatten
      end
    end
def search_condition if search_support? && params [ :q ] . present? terms = params [ :q ] . split ( / \s + / ) . collect { | t | "%#{t}%" } clause = search_columns . collect do | f | col = f . to_s . include? ( '.' ) ? f : "#{model_class.table_name}.#{f}" "#{col} LIKE ?" end . join ( " OR " ) clause = terms . collect { | t | "(#{clause})" } . join ( " AND " ) [ "(#{clause})" ] + terms . collect { | t | [ t ] * search_columns . size } . flatten end end
Compose the search condition with a basic SQL OR query.
Compose the search condition with a basic SQL OR query .