There are articles and stackoverflow answers that sample the general opinion that pluck
is the superior method to use over map
and select
. I agree on that with map
, but I beg to differ for select
on some "select" cases, and for good reason.
Usually, pluck
is being used when there is some special chain of queries that are needed to be called on a complicated application. A sample of this call that I usually see is:
discounted_product_ids = Product.with_discounts.where(country: 'AU').pluck(:id)
promo_product_ids = Product.with_promos.where(country: 'AU').pluck(:id)
products = Product.where(id: discounted_product_ids + promo_product_ids)