Pluck last value of an association in rails
The model Price has an attribute data, so
Price.pluck(:data)
results in something like [3.99,4.55,5.44]
And Price belongs to Vendor
So I want to select the best price for each vendor, something like
Vendor.all.pluck(prices.order("data ASC").first.data)
How can I go about extracting the lowest price data element for each
vendor in this scenario? Thank you in advance for the help.
No comments:
Post a Comment