Q:

Rails, including more than one relationship in the scope of a model

I have the following scope that returns all the products that have branch_id = 1, and also have the attribute enabled set to true. 
scope :enabled_product, -> {includes(:products).where("products.branch_id = ?", 1).where(products: {enabled: true})}

Product also has a many to many relationship to Category. How can I include the categories for each product in this scope?

A:

includes(:products => [:categories])

