Hi everyone,
When ordering from multiple suppliers at the same time, it would be useful to be able to work on multiple orders at the same time. E.g. viewing all articles an ordergroup is taking home, or a “Group PDF” containing all relevant (e.g. closed-but-not-finished) orders.
One approach is to allow “1+2+3” style ids, like ``, which would show all articles from orders 1, 2 and 3. This is the approach I’m using in foodcoop-adam’s combined group pdf. A downside is that one can’t load all relevant data in the controller: while getting the order’s articles used to be @order.order_articles
, it becomes OrderArticle.where(order_id: @order_ids)
which doesn’t allow for preloading using includes()
.
Another approach might be to have some kind of Order
-like object containing multiple orders. I don’t really know how that would look like though.
Is there a best practice for working with multiple objects in Rails?
Any input is welcome on this!
- Willem