Sha256: 5d585a5134400d780d24ad4434d472754db8605377c478381e9c51dda3d06722

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

module Hive
  
  # Tracks post tags.
  # 
  # To grab the top 100 tags, grouped by post count:
  # 
  #     Hive::PostTag.top_count(:tag, 100)
  #     Hive::PostTag.top_count # same as #top_count
  class PostTag < Base
    self.table_name = :hive_post_tags
    self.primary_keys = %i(post_id tag)
    
    belongs_to :post
    
    scope :top_count, lambda { |what = :tag, limit = 100|
      group(what).limit(limit).order('count_all desc').count
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hivemind-ruby-0.1.0 lib/hive/models/post_tag.rb