It seems impossible to give any and arguments that make it do nothing. However, you can simply call and conditionally:
def sql billing_requests .project(billing_requests[Arel.star]) .where(filter_by_day_and_merchant_and_operator_name) .to_sql end def filter_by_day billing_requests[:created_at].gteq(@start_date).and( billing_requests[:created_at].lteq(@end_date) ) end def filter_by_merchant billing_requests[:merchant_id].eq(@merchant_id) end def filter_by_operator_name billing_requests[:operator_name].eq(@operator_name) end def filter_by_day_and_merchant if @merchant_id.blank? filter_by_day else filter_by_day.and(filter_by_merchant) end end def filter_by_day_and_merchant_and_operator_name if @operator_name.blank? filter_by_day_and_merchant else filter_by_day_and_merchant.and(filter_by_operator_name) end end private def billing_requests @table ||= Arel::Table.new(:billing_requests) end
This is very awkward, but he is doing his job.
source share