比方说包括我们有3个表:嵌套其中on Rails的
products (title, product_type_id)
product_types (title)
product_type_options (product_type_id, size)
我要加载的产品,它的类型&只有特定product_type_options(product_type_options.size = 'XL'
)
是否有可能不施氮做+ 1在轨道查询?
喜欢的东西:
Product.includes(product_type: [product_type_options])
.where("product_type_options.size = 'XL'")
我不能让它使用where
参数工作。任何想法?
你得到了什么错误?您需要从查询 –