Looks like you need not array but hash like this
more_than = { ios: 13, android: 14 }
You can build SQL condition string with sanitize_sql_for_conditions from array with placeholders
sql_condition_array = more_than.each_with_object([]) do |(atr, value), sql_array| if sql_array.empty? sql_array[0] = "#{atr} > ?" else sql_array[0] << " OR #{atr} > ?" end sql_array << value end # => ["ios > ? OR android > ?", 13, 14] sql_condition = Control.sanitize_sql_for_conditions(sql_condition_array) # => "ios > 13 OR android > 14"
or may be directly
sql_condition = more_than.map { |atr, value| "#{atr} > #{value}" }.join(" OR ") # => "ios > 13 OR android > 14"
And then
Control.where(company_id: 12345).where(sql_condition)
The query will be like this:
SELECT "controls".* FROM "controls" WHERE "controls"."company_id" = 12345 AND (ios > 13 OR android > 14);
If that hash will consist of just one element, there will be not OR used like this:
SELECT "controls".* FROM "controls" WHERE "controls"."company_id" = 12345 AND (ios > 13);