Can you use the Enumerable.all? method Enumerable.all? :
%i( p1 p2 p3 ).all? { |key| params[key].present? }
Another alternative, if you need values, is to select them and check for availability.
params.values_at(*%i( p1 p2 p3 )).all?(&:present?)
or
params.values_at(:p1, :p2, :p3).all?(&:present?)
source share