samedi 12 novembre 2016

joins from belongs_to where query not working

I have been trying joins from the has_many table and i'm able to get it like Order has_many order_items

Order.joins(:order_items).where(order_items: {name: 'something'})

But if i try from belongs_to table like

OrderItem.joins(:order).where(order: {value: 'something'})

I tried searching with keyword belongs_to, joins i wasnt able to get it

Aucun commentaire:

Enregistrer un commentaire