Get An Array Of Values From The Database
> Product.where(available: true).pluck(:sku)
[ "efg-1234", "pqr-3455", ... ]> ActiveRecord::Base.connection.execute(<<-SQL)
select split_part(sku, '-', 1) product_type
from products
where available = true;
SQL
[{ "product_type" => "efg" }, { "product_type" => "pqr" }, ... ]> ActiveRecord::Base.connection.select_values(<<-SQL)
select split_part(sku, '-', 1) product_type
from products
where available = true;
SQL
[ "efg", "pqr", ... ]Last updated