I'm dealing with a shopping cart, which has many products in it. The products can be sold by multiple different companies. What I'm trying to do is select the companies uniquely so that I can create one order per vendor.
the hack
companies = []
@cart.products.each { |p| companies << p.company }
companies.uniq
#create order for each company
I'm not sure if #pluck
is something I should be using here, but I do know that there has got to be a more efficient way of collecting my companies "uniquely". #uniq
doesn't seem to be working for me, and neither does @cart.products.pluck(:company)
I have no :company_id
in my Bid model, it's a has_many/has_one
relationship