Hi,
I would like to show my 5 most active tags. (most used)
I did the following but I have a feeling the results are not correct.
#tag.rb
class Tag < ApplicationRecord
has_many :taggings, :dependent => :delete_all
has_many :posts, through: :taggings
scope :top5, -> {
self.select("tags.id, tags.name, count(taggings.id) as count").joins(:taggings).group("tags.id").limit(5).order('count DESC')
}
Does this seem correct? I am using pg. Thanks