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)
Written by lazybios
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#