irb> Order.group(:status).count
=> {"being_packed"=>7, "shipped"=>12}
Code language: PHP (php)
Product.group(:title)
#<ActiveRecord::Relation
[#<Product id: 5, title: "Build Chatbot Interactions", description: "<p>\n <em>Responsive, Intuitive Interfaces wit...", image_url: "dpchat.jpg", price: 0.2e2, created_at: "2021-02-15 18:08:44", updated_at: "2021-02-15 18:08:44">,
#<Product id: 4, title: "Docker for Rails Developers", description: "<p>\n <em>Build, Ship, and Run Your Applicatio...", image_url: "ridocker.jpg", price: 0.38e2, created_at: "2021-02-15 18:08:44", updated_at: "2021-02-15 18:08:44">,
#<Product id: 6, title: "Programming Crystal", description: "<p>\n <em>Create High-Performance, Safe, Concu...", image_url: "crystal.jpg", price: 0.4e2, created_at: "2021-02-15 18:08:44", updated_at: "2021-02-15 18:08:44">]>
Code language: PHP (php)