def build_search_query
        string = params[:search].split ' '
        redeem_codes = DealRedemptions::RedeemCode.arel_table
        companies = DealRedemptions::Company.arel_table
        query = redeem_codes.project(
          redeem_codes[:id],
          redeem_codes[:company_id],
          redeem_codes[:code],
          redeem_codes[:status],
          redeem_codes[:created_at]
        )
        .join(companies)
        .on(redeem_codes[:company_id]
            .eq(companies[:id]))

        string.each do |s|
          query.where(redeem_codes[:code].matches("%#{s}%"))
        end

        query.to_sql
      end
def build_search_query
        string = params[:search].split ' '
        redeem_codes = DealRedemptions::RedeemCode.arel_table
        companies = DealRedemptions::Company.arel_table
        query = redeem_codes.project(
          redeem_codes[:id],
          redeem_codes[:company_id],
          redeem_codes[:code],
          redeem_codes[:status],
          redeem_codes[:created_at]
        )
        .join(companies)
        .on(redeem_codes[:company_id]
            .eq(companies[:id]))

        string.each do |s|
          query.where(redeem_codes[:code].matches("%#{s}%"))
        end

        query.to_sql
      end
Search redemption codes