most frequent value in active record coloumn

Just wanted to ask does anyone know how to find the 5 most frequent values in a model colomn for active record.



How would I find the top 5 most common countries


Use the following'count_id DESC').limit(5).count(:id)
Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .