Я хотел бы объединить два запроса, используя «ИЛИ» Active Record:
@category_ids = [4,5,6,7]
@sub_category_ids = [1,3,5,6]
@products1 = @products.joins(:inventory_categorizations).distinct.where(inventory_categorizations: {inventory_category_id: @sub_category_ids, inventory_category_type: "SubCategory"})
@products2 = @products.joins(:inventory_categorizations).distinct.where(inventory_categorizations: {inventory_category_id: @category_ids, inventory_category_type: "Category"})
@products = @products1 | @products2
Есть ли возможность использовать это?
@products = @products.joins(:inventory_categorizations).distinct.where(inventory_categorizations: {inventory_category_id: @sub_category_ids, inventory_category_type: "SubCategory" or inventory_category_id: @category_ids, inventory_category_type: "Category"})