I have a table called Delivery that looks like this:
class Delivery
...
has_many :delivery_products
has_many :products, through: delivery_products
end
DeliveryProducts is a joined table:
class DeliveryProduct
belongs_to :delivery
belongs_to :product
end
In my tests, I have some factories that create a delivery_product with a delivery:
create(:delivery_product, delivery: delivery, product: wine.product, product_slot: product_slot)
However, when I try to grab the delivery_products via the delivery, I can't seem to do this:
delivery.delivery_products
=> []
However, delivery.products does indeed return me the items.
Is there an issue with grabbing the rows of the joined table?
Aucun commentaire:
Enregistrer un commentaire