ovxrta
Last Updated: June 14, 2017
·
2
· lazybios
97eb92522d043b54ef01a9128b7176c0

order by association count

Author.joins(:articles).select("count(articles.id) as article_count").group("authors.id").order("article_count")

add index to counter_cache column and order by it.

scope :hot, oder(:articles_count)
Say Thanks
Respond